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
BlackBerry Development Advisor
chadtatro
Posts: 620
Registered: ‎10-01-2009
My Device: Z10

OAuth: Twitter, Facebook & Foursquare Samples!

[ Edited ]

Hello,

 

In case you missed it last week, we published three sample apps which show how to integrate OAuth (v1, and 2) into your WebWorks app!

 

There are sample apps available for: Twitter, Facebook, and Foursquare

 

Blog Post: http://devblog.blackberry.com/2012/10/say-it-aint-soauth/#comment-679033147

 

Sample Apps: https://github.com/blackberry/BB10-WebWorks-Samples

Chad Tetreault | App Development Consultant | BlackBerry Developer Relations | developer.blackberry.com | @chadtatro
Please use plain text.
New Contributor
yey2000
Posts: 5
Registered: ‎10-29-2012
My Device: Dev Alpha B, 9810, Developer

Re: OAuth: Twitter, Facebook & Foursquare Samples!

Hi

 

1. I have some questions on the oAuth2 samples. It looks like to have a working and secure webworks app using oAuth2. The callback program must be hosted on a web server. Is there way to get around that? To have a server component for webworks app that only need some API access seems expensive.

 

2. Do you have an sample for oAuth on Google API? When registering app on google, the webworks app should be considered "web Applications" or "Installed Applications"?

 

Thanks a lot.

Yi

 

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

Re: OAuth: Twitter, Facebook & Foursquare Samples!

Right now there is no way around the server side.  We are working on optimizing our Child Browser API and hope that this will eliminate the need for that.

 

I don't have a Google example, but I would assume you would want it to be considered an "installed app"

Chad Tetreault | App Development Consultant | BlackBerry Developer Relations | developer.blackberry.com | @chadtatro
Please use plain text.
Contributor
mrmartis
Posts: 33
Registered: ‎08-24-2012
My Device: BB9900, Playbook Wifi 32 GB, BB10 Dev Alpha

Re: OAuth: Twitter, Facebook & Foursquare Samples!

I am trying to incorporate Facebook Auth in my app and OAuth sample in the WebWorks sample is giving me errors:

 

1. I am getting a reference error that says variable facebookOptions can't be found. 

 

2. The redirect file, should the address be different than local///index.html? on the dev alpha? 

 

I posted the question in stackoverflow, here is the link to the code and more:

http://stackoverflow.com/questions/13733791/web-mobile-application-facebook-oauth

 

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

Re: OAuth: Twitter, Facebook & Foursquare Samples!

I have just updates all the OAuth samples to work in the newest SDK. 

 

Get the updated sample from: https://github.com/blackberry/BB10-WebWorks-Samples

 

For #1 -- The problem is that the initApp function wasn't being executed.  This is because the webworksready event wasn't being fired.  Now that the samples have been update to reflect the new way of including the webworks.js file, this should no longer be an issue.

 

For #2 -- Nope,  in the .php file you'll want it to be local:///index.html.  NOTE:  this assumes that your main index page is actually named "index.html", if it's different, then you'll need to update the .php file to reference it.

 

 

Chad Tetreault | App Development Consultant | BlackBerry Developer Relations | developer.blackberry.com | @chadtatro
Please use plain text.
New Contributor
yey2000
Posts: 5
Registered: ‎10-29-2012
My Device: Dev Alpha B, 9810, Developer

Re: OAuth: Twitter, Facebook & Foursquare Samples!

Any target date for the improved Child Browser API support?

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

Re: OAuth: Twitter, Facebook & Foursquare Samples!

Nothing yet, but they are working on it.  

Chad Tetreault | App Development Consultant | BlackBerry Developer Relations | developer.blackberry.com | @chadtatro
Please use plain text.
Developer
madmaskd
Posts: 137
Registered: ‎07-24-2012
My Device: Blackberry Z10 LE, Q10 And PlayBook

Re: OAuth: Twitter, Facebook & Foursquare Samples!

need Direct code to Put into Web Works app this Samples given in Github link has too many Samples we often spend More time in Searching the Suff .. (Need Ditect code to put into .. ) Fb must be Reflected in our App Any Help is Appreacitable

Hit Like if you find my post Use Full Thank You...
Please use plain text.
BlackBerry Development Advisor
chadtatro
Posts: 620
Registered: ‎10-01-2009
My Device: Z10

Re: OAuth: Twitter, Facebook & Foursquare Samples!

The samples on github are about as bare-bones as I can really make them.  

 

You should be able to follow the code, it's commented and should follow the proper flow.  The blog post talks about OAuth in a bit more detail as well 

 

http://devblog.blackberry.com/2012/10/say-it-aint-soauth/

 

 

Chad Tetreault | App Development Consultant | BlackBerry Developer Relations | developer.blackberry.com | @chadtatro
Please use plain text.
New Contributor
mushtaq34
Posts: 3
Registered: ‎12-27-2012
My Device: Blackberry10 Dev Alpha

Re: OAuth: Twitter, Facebook & Foursquare Samples!

Hi, Here is the sample code to get a refresh token and access token from Google,
/* login */
function GMlogin(){
try {
top.location.replace('https://accounts.google.com/o/oauth2/auth?scope=https://www.googleapis.com/auth/userinfo.email+
https://www.googleapis.com/auth/userinfo.profile&response_type=code&redirect_uri='+serverURL+'
&approval_prompt=force&state=/profile&client_id='+GMappID+'&access_type=offline');
}catch (e) {} }

/* Refresh Token and Access Token */
function getGMAccessToken(){
try {
var url = 'https://accounts.google.com/o/oauth2/token';
var Pdata = 'code='+GMauthCode+'&client_id='+GMappID+'&client_secret='+GMappSecret+'&redirect_uri='+serverURL+'&grant_type=authorization_code';
$.ajax({
type: 'POST',
url: url,
data: Pdata,
success: function( rdata ) {
alert(JSON.stringify(rdata));
}, error: function(data) {}
});
} catch (e) {} }

Please use plain text.