本文介绍了如何通过chrome.identity获得使用Oauth2的Facebook令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在打包的应用程序中使用chrome.identity来使用Facebook获取用户令牌。我调用chrome.identity.launchWebAuthFlow,并且需要将访问令牌发送给服务器,然后使用访问令牌来验证用户。



与Google+合作非常好。但由于某种原因,它不适用于Facebook。出于某种原因,Facebook的OAuth看起来很特别。我已将extensionid.chromiumapp.org添加到API中的重定向网址列表中。新增

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

转换为manifest.json。但是没有任何变化。



在调用chrome.identity.launchWebAuthFlow时,我使用这样的URL

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

当我尝试调用它时,我收到以下错误消息:

 launchWebAuthFlow completed Object {message:授权页面无法加载。} $ 

当我使用URL时,如

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

我得到下一个错误:

 launchWebAuthFlow completed Object {message:User interaction required。} undefined»

我尝试在4天内获得Facebook令牌。我累了。我做错了什么?
为什么chrome.identity.getAuthToken适用于Google+和chrome.identity.launchWebAuthFlow不与Facebook?

我希望有人做了同样的事情并且可以提供帮助我。

解决方案

我已经解决了这个问题。以下是示例


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.

解决方案

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

这篇关于如何通过chrome.identity获得使用Oauth2的Facebook令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 17:28