Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Trusted Contributor
AllSystemGo
Posts: 140
Registered: ‎11-23-2010
My Device: Torch 9800

oAuth2 question

[ Edited ]

The app I'm trying to create supports oauth2 and since I'm really new at this I would really appreciate if someone could help me understand what I need to code or how to use the library that Kyle Fowler created.

 

My website needs these parameter to be sent:

 

  • consumer_key
  • redirect_uri

I want to unserstand what is the redirect_uri I need to input. And finally how to I end up with something like that:

 

Example request (x-www-form-urlencoded):

POST /v3/oauth/request HTTP/1.1
Host: 
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
X-Accept: application/x-www-form-urlencoded

consumer_key=1234-abcd1234abcd1234abcd1234&
redirect_uri=myapp1234:authorizationFinished

 

 

Thank you for the help.

Developer
Innovatology
Posts: 1,280
Registered: ‎03-03-2011
My Device: Playbook, Z10, Q10, Z30 with Files & Folders and Orbit of course

Re: oAuth2 question

On mobile devices, the easiest way of handling OAuth is by using an embedded web view. In that case, the redirect URI is just a string. Any string. It could be the name of your pet goldfish. Or a randomly generated string. As long as it doesn't occur in the normal oauth dance you're fine. You simply use it to detect when your token has been generated by handling the navigation event of the web view:

 

  • oath process is started in the web view
  • user logs in, grants permission
  • site generates token
  • site redirects to redirect_uri
  • webview fires navigation event
  • your app detects navigation to redirect_uri
  • your app extracts token from redirect_uri
  • your app cancels navigation, removes webview

For historical reasons, the prefix oob:// (meaning out-of-band) is often used, but there is no requirement for that.

 

Files & Folders, the unified file & cloud manager for PlayBook and BB10 with SkyDrive, SugarSync, Box, Dropbox, Google Drive, Google Docs. Free 3-day trial! - Jon Webb - Innovatology - Utrecht, Netherlands
Developer
kylefowler
Posts: 526
Registered: ‎05-17-2009
My Device: 9900

Re: oAuth2 question

There is an oauth2 sample on my github. http://github.com/kylefowler
Like all of my posts
Trusted Contributor
AllSystemGo
Posts: 140
Registered: ‎11-23-2010
My Device: Torch 9800

Re: oAuth2 question

Wow, really great answer thank you. I really appreciate the time you spend on answering my question.
Trusted Contributor
AllSystemGo
Posts: 140
Registered: ‎11-23-2010
My Device: Torch 9800

Re: oAuth2 question

Thank you for your post Kyle. Which one is oauth2 sample? I tried the twitter one but I don't think that it uses oauth2. I could be mistaken!
Developer
kylefowler
Posts: 526
Registered: ‎05-17-2009
My Device: 9900

Re: oAuth2 question

Yeah, twitter uses oauth1. The foursquare one is oauth2 https://github.com/kylefowler/foursquare
Like all of my posts
Visitor
tatli
Posts: 1
Registered: ‎02-08-2013
My Device: Simulator

Re: oAuth2 question

This approach would not work (for "https" uri) at least from my experience. Cascades WebView is not handling redirect_uri properly (whereas browser does it perfectly).
Developer
wantoun
Posts: 165
Registered: ‎10-04-2010
My Device: P'9982 & Z10

Re: oAuth2 question

I'm having the same problem as tatli with secure content.
I'm trying to use Google's OAuth but I can't load the URLs with HTTPS.
Anyone managed to work around that!?
Wadi