我在打包的應用程序中使用chrome.identity來獲取使用Facebook的用戶令牌。我調用chrome.identity.launchWebAuthFlow,並且需要將訪問令牌發送給服務器,然後使用訪問令牌來驗證用戶。如何獲取Facebook令牌使用Oauth2與chrome.identity
適用於Google+。但由於某種原因,它不適用於Facebook。出於某種原因,Facebook的OAuth看起來很特別。我已將extensionid.chromiumapp.org添加到API中的重定向網址列表中。添加
"https://extensionid.chromiumapp.org/*",
"https://facebook.com/*",
"https://www.facebook.com/dialog/",
"https://graph.facebook.com/*"
to 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: "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?
我希望有人做了同樣的事情,可以幫助我。
不提醒你什麼?調用crome.identity.launchWebAuthFlow()時是否使用了「交互式」標誌? –
我使用 - chrome.identity.launchWebAuthFlow({'interactive':false,'url':authUrl},function(token){});和 - var authUrl =「https://www.facebook.com/dialog/oauth/access_token?"+ 」client_id = myclientId&client_secret = myclientSecret&「+ 」response_type = token「; – user3215200
您是否嘗試將「交互式」更改爲true? –