admin管理员组文章数量:1277896
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 to the list of redirect URLs in the API. Added
"/*",
"/*",
"/",
"/*"
to manifest.json. But nothing changed.
In calling chrome.identity.launchWebAuthFlow I use URL like this
"?" +
"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 pleted Object {message: "Authorization page could not be loaded."} »
And when I use URL like
«";redirect_uri==token&scope=user"»
I get the next error:
«launchWebAuthFlow pleted 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.
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 to the list of redirect URLs in the API. Added
"https://extensionid.chromiumapp/*",
"https://facebook./*",
"https://www.facebook./dialog/",
"https://graph.facebook./*"
to manifest.json. But nothing changed.
In calling chrome.identity.launchWebAuthFlow I use URL like this
"https://www.facebook./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 pleted Object {message: "Authorization page could not be loaded."} »
And when I use URL like
«"https://www.facebook./dialog/oauth?client_id=myclientid&redirect_uri=https://myextensionid.chromiumapp/facebook.=token&scope=user"»
I get the next error:
«launchWebAuthFlow pleted 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.
Share Improve this question asked Jan 23, 2014 at 15:30 user3215200user3215200 1711 silver badge5 bronze badges 3- Doesn't "User interaction required." remind you anything? Did you use "interactive" flag when calling crome.identity.launchWebAuthFlow()? – Dmitrii Sorin Commented Jan 23, 2014 at 18:04
- I use — chrome.identity.launchWebAuthFlow({ 'interactive': false, 'url':authUrl}, function(token) {}); and — var authUrl = "facebook./dialog/oauth/access_token?"+ "client_id=myclientId&client_secret=myclientSecret&" + "response_type=token"; – user3215200 Commented Jan 23, 2014 at 20:07
- 1 Did you try changing "interactive" to true? – Dmitrii Sorin Commented Jan 24, 2014 at 15:36
3 Answers
Reset to default 9I have solved the problem. Here is an example https://github./blackgirl/Facebook_Oauth2_sample_for_extensions
The "User interaction required." message means that the user needs to sign in to Facebook, and/or approve the requested OAuth scopes. The setting the { interactive: true } flag would allow identity.launchWebAuthFlow to display a window where the user would perform these steps. Since you are passing the { interactive: false } flag, identity.lauchWebAuthFlow fails.
https://www.facebook./dialog/oauth
is most likely the URL you want to use to start your flow. The client_credentials grants are normally for cases where you are accessing resources owned by your app, rather than resources owned by a specific user.
However if you did want to debug that "Authorization page could not be loaded" case, the way to do it would be to open up chrome://net-internals and look for error responses ing back from Facebook.
chrome.identity.launchWebAuthFlow(
{'url': 'https://www.facebook./dialog/oauth?client_id=myclientid&redirect_uri=https://myextensionid.chromiumapp/facebook.=token&scope=user, 'interactive': true},
function(redirect_url) {
/* Extract token from redirect_url */
console.log(redirect_url);
});
//'interactive': true
what will this flag do, will show a dialog box asking username and password upon successful login it will ask for grant access just press that and you will receive redirect url in above function body.
本文标签: javascriptHow get Facebook token using Oauth2 with chromeidentityStack Overflow
版权声明:本文标题:javascript - How get Facebook token using Oauth2 with chrome.identity - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741274069a2369626.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论