如果您使用的是InAppBrowser插件,您可以從Facebook登錄獲取URL。 Facebook身份驗證令牌應該是其中的一部分。
類似於發生在這裏(OpenFB)什麼:
/**
* Called either by oauthcallback.html (when the app is running the browser) or by the loginWindow loadstart event
* handler defined in the login() function (when the app is running in the Cordova/PhoneGap container).
* @param url - The oautchRedictURL called by Facebook with the access_token in the querystring at the ned of the
* OAuth workflow.
*/
function oauthCallback(url) {
// Parse the OAuth data received from Facebook
var queryString,
obj;
loginProcessed = true;
if (url.indexOf("access_token=") > 0) {
queryString = url.substr(url.indexOf('#') + 1);
obj = parseQueryString(queryString);
tokenStore['fbtoken'] = obj['access_token'];
if (loginCallback) loginCallback({status: 'connected', authResponse: {token: obj['access_token']}});
} else if (url.indexOf("error=") > 0) {
queryString = url.substring(url.indexOf('?') + 1, url.indexOf('#'));
obj = parseQueryString(queryString);
if (loginCallback) loginCallback({status: 'not_authorized', error: obj.error});
} else {
if (loginCallback) loginCallback({status: 'not_authorized'});
}
}
基於OAuth的認證過程是沒有問題的。在oauth之後,我想在Facebook上打開帖子或消息。在這一點上,即使用戶登錄到我的應用程序(oauth),我猜測,應用程序內瀏覽器沒有auth cookie,因此用戶會看到另一個登錄屏幕。 – nicholas