Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How get Facebook token using Oauth2 with chrome.identity

I'm using chrome.identity in a packaged app to get a user token using Facebook. I call chrome.identity.launchWebAuthFlow, and I need to take the access token, send it to the server, and then access token is used to verify the user.

Works great with Google+. But for some reason, it doesn't work for Facebook. For some reason, Facebook's OAuth appears to be special. I've added the extensionid.chromiumapp.org to the list of redirect URLs in the API. Added

"https://extensionid.chromiumapp.org/*",
    "https://facebook.com/*",
    "https://www.facebook.com/dialog/",
    "https://graph.facebook.com/*"

to manifest.json. But nothing changed.

In calling chrome.identity.launchWebAuthFlow I use URL like this

"https://www.facebook.com/dialog/oauth/access_token?" +
                   "client_id=myclientid&client_secret=myclientsecret&" + 
                  "response_type=token&grant_type=client_credentials"

When I try to invoke it, I get the following error message:

«launchWebAuthFlow completed Object {message: "Authorization page could not be loaded."} »

And when I use URL like

«"https://www.facebook.com/dialog/oauth?client_id=myclientid&redirect_uri=https://myextensionid.chromiumapp.org/facebook.com=token&scope=user"» 

I get the next error:

«launchWebAuthFlow completed Object {message: "User interaction required."} undefined »

I try to get facebook token in 4 days. I am tired. What I do wrong? Why chrome.identity.getAuthToken work great for Google+ and chrome.identity.launchWebAuthFlow dont with Facebook?

I hope someone have done the same things and can help me.

like image 241
user3215200 Avatar asked Jan 23 '14 15:01

user3215200


People also ask

Is Facebook using OAuth?

OAuth is also used when giving third-party apps access to accounts like your Twitter, Facebook, Google, or Microsoft accounts. It allows these third-party apps access to parts of your account.


1 Answers

I have solved the problem. Here is an example https://github.com/blackgirl/Facebook_Oauth2_sample_for_extensions

like image 167
user3215200 Avatar answered Oct 12 '22 03:10

user3215200