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

Web and WebWorks Development

Reply
Developer
fantas
Posts: 107
Registered: ‎02-10-2012
My Device: Limited Developer Edition
My Carrier: WiFi

Re: OAuth: Twitter, Facebook & Foursquare Samples!

Blackberry is really delivering, love their github channel
If i've helped you use the like button (KUDOS)!
Follow me at twitter: @hektorc
Read my blog: http://hektor.in
Check my GitHub: github.com/hektorcyc
Please use plain text.
Developer
wantoun
Posts: 165
Registered: ‎10-04-2010
My Device: P'9982 & Z10
My Carrier: alfa Lebanon

Re: OAuth: Twitter, Facebook & Foursquare Samples!

The samples are great, I didn't even realise I can open a new "window" in a WebWorks app - definetly got me to go to HTML5 over Cascades!

 

Anyways, I'm trying to use OAuth 2.0 with Google's API. The problem is Google only lets you set two options as a redirect URI:

Redirect URIs:

urn:ietf:wg:smileysurprised:auth:2.0:smileysurprised:ob

http://localhost

 

Seeing that those two URIs end up with a different domain than WebWork's default local///index.html, I am unable to access the code generated by Google from the child window with these lines:

childWindow   window.open(url,'_blank');

varcurrentURLchildWindow.window.location.href;

 

Is there a workaround for this? I've been going all over the web but can't seem to get a way!

Wadi
Please use plain text.
New Developer
kaihiong
Posts: 31
Registered: ‎05-18-2012
My Device: Blackberry Z10
My Carrier: SingTel

Re: OAuth: Twitter, Facebook & Foursquare Samples!

Thanks! Appreciate the samples
Please use plain text.
BlackBerry Development Advisor
chadtatro
Posts: 614
Registered: ‎10-01-2009
My Device: Z10
My Carrier: Bell

Re: OAuth: Twitter, Facebook & Foursquare Samples!

This block of code should detect when the childWindow is redirected to your callback url

 

https://github.com/ctetreault/BB10-WebWorks-Samples/blob/master/Twitter-OAuth-1/js/app.js#L85-L106

 

		var callbackURL = twitterOptions.callbackUrl;
		var inCallback = currentURL.indexOf(callbackURL);

		// location has changed to our callback url, parse the oauth code
		if(inCallback == 0) {

			// stop the interval from checking for url changes	
			window.clearInterval(int)

			// parse the oauth codes
			var oauthToken = checkForQueryStrings('oauth_token') || null;
			var oauthVerifier = checkForQueryStrings('oauth_verifier') || null;

			// close the childWindow
			childWindow.close();

			setTimeout(function() {
				getOAuthToken(oauthToken, oauthVerifier);
			}, 1000);
		}

 

Chad Tetreault | App Development Consultant | BlackBerry Developer Relations | developer.blackberry.com | @chadtatro
Please use plain text.
Developer
wantoun
Posts: 165
Registered: ‎10-04-2010
My Device: P'9982 & Z10
My Carrier: alfa Lebanon

Re: OAuth: Twitter, Facebook & Foursquare Samples!

Thanks for getting back to me Chad, but the problem is not the code itself, but the callback url.

Google only allows you 2 URLs for an "installed" app.

urn:ietf:wgauth:2.0ob

OR

http://localhost


Both options are different from the BlackBerry's default local///index.html URL, and so the browser doesn't have access to the childWindow's URL in the first place.

Wadi
Please use plain text.
BlackBerry Development Advisor
chadtatro
Posts: 614
Registered: ‎10-01-2009
My Device: Z10
My Carrier: Bell

Re: OAuth: Twitter, Facebook & Foursquare Samples!

Oh I see.  Im afraid I don't have a solution right now then.  I'm a bit surprised they don't allow other callbacks :\

Chad Tetreault | App Development Consultant | BlackBerry Developer Relations | developer.blackberry.com | @chadtatro
Please use plain text.
Regular Contributor
hitesh171285
Posts: 95
Registered: ‎07-16-2010
My Device: 8520
My Carrier: bsnl

Re: OAuth: Twitter, Facebook & Foursquare Samples!

Hii

how can i mane Google auth2.0 is any library ?
Please use plain text.
BlackBerry Development Advisor
chadtatro
Posts: 614
Registered: ‎10-01-2009
My Device: Z10
My Carrier: Bell

Re: OAuth: Twitter, Facebook & Foursquare Samples!

Looks like Google has quite a bit on info over here -> https://developers.google.com/accounts/docs/OAuth2

Chad Tetreault | App Development Consultant | BlackBerry Developer Relations | developer.blackberry.com | @chadtatro
Please use plain text.
New Member
mkiisoft
Posts: 1
Registered: ‎07-21-2013
My Device: Dev Alpha A
My Carrier: 5493543603253

Re: OAuth: Twitter, Facebook & Foursquare Samples!

Hello everyone! I've that Twitter update his API to 1.1 (1.0 no longer funtion)... any idea if you'll update the samples?! I've been working with 1.1 API but in J2SE getting to work like a charm. If you guys need any help or there is any change to update that API... get me a call.
Please use plain text.
BlackBerry Development Advisor
chadtatro
Posts: 614
Registered: ‎10-01-2009
My Device: Z10
My Carrier: Bell

Re: OAuth: Twitter, Facebook & Foursquare Samples!

They are on my list of things to update, but I won't be able to get to them for a little while yet.

 

However, since they're on GitHub feel free to do a pull request if you like :smileyhappy:

Chad Tetreault | App Development Consultant | BlackBerry Developer Relations | developer.blackberry.com | @chadtatro
Please use plain text.