如何使用带有 chrome.identity 的 Oauth2 获取 Facebook 令牌 [英] How get Facebook token using Oauth2 with chrome.identity

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

问题描述

我在打包的应用程序中使用 chrome.identity 来获取使用 Facebook 的用户令牌.我调用了chrome.identity.launchWebAuthFlow,需要拿到access token,发送到服务器,然后用access token验证用户.

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.

与 Google+ 搭配使用效果很好.但出于某种原因,它不适用于 Facebook.出于某种原因,Facebook 的 OAuth 似乎很特别.我已将 extensionid.chromiumapp.org 添加到 API 中的重定向 URL 列表中.添加

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/*"

到 manifest.json.但一切都没有改变.

to manifest.json. But nothing changed.

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

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."} »

当我使用像

«"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 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.

推荐答案

我已经解决了这个问题.这是一个示例 https://github.com/blackgirl/Facebook_Oauth2_sample_for_extensions

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

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆