我有一個問題,當我開發我的網站Google+登錄: 我也一步一步的文檔告訴我,但我始終沒在第四步: https://developers.google.com/+/web/signin/「immediate_failed」 - 無法automatially登錄的用戶
結果總是「」 immediate_failed「 - 無法automatially登錄的用戶」,我只是不kown爲什麼,誰能幫助我,非常感謝! :-(
我有一個問題,當我開發我的網站Google+登錄: 我也一步一步的文檔告訴我,但我始終沒在第四步: https://developers.google.com/+/web/signin/「immediate_failed」 - 無法automatially登錄的用戶
結果總是「」 immediate_failed「 - 無法automatially登錄的用戶」,我只是不kown爲什麼,誰能幫助我,非常感謝! :-(
請注意,在您指出的示例代碼中,「immediate_failed」檢查被註釋掉了。這是有意的,因爲用戶第一次遇到頁面上的登錄按鈕時,它將失敗。
它失敗的原因是,當頁面首次加載時,甚至在用戶按下按鈕之前,會向Google發送請求,以確定用戶是否已經登錄(例如,通過Google或其他站點)。如果他們是 - 他們沒有必要再次登錄,所以按鈕不需要顯示,但如果他們有而不是已經登錄,你會得到「immediate_failed」響應,並且需要顯示(或不清除)按鈕。
tl; dr - 當頁面第一次加載時,不要擔心不會獲得immediate_failed。這個是正常的。
這是在[Javascript快速入門頁面](https://developers.google.com/sheets/api/quickstart/js)上的工作示例中顯示的。 – LondonRob 2017-01-13 19:01:02
作爲一種變通方法我在gapi.auth.signIn回調使用gapi.auth.authorize方法。這是我的代碼:
gapi.auth.signIn({
'callback': gPlusLoginCallback
});
function gPlusLoginCallback(authResult) {
if (authResult['status']['signed_in']) {
doSmth(authRes['access_token']);
} else if (authResult['error'] == "immediate_failed") {
gapi.auth.authorize({
client_id: gplusClientId,
scope: 'https://www.googleapis.com/auth/plus.login email',
immediate: true
}, function (authRes) {
if (authRes['status']['signed_in']) {
doSmth(authRes['access_token']);
}
});
}
}
function doSmth(accessToken){
//Do smth
}
將此設置更改爲「immediate:true」,將其設置爲false「immediate:false」。 但是如果你喜歡讓更復雜的實現看看這裏的第一個示例https://developers.google.com/api-client-library/javascript/start/start-js。你必須向谷歌的召喚「gapi.auth.authorize({...」,第一個用「立竿見影:真」,而第二個具有「立竿見影:假」。
謝謝!這對我有效。 – SsjCosty 2015-05-16 23:10:00
的問題是舊的,但我最近面臨這個問題。
在我的情況,那是因爲我指定的URI parameterprompt
到none
。我想谷歌不喜歡,如果用戶之前從未登錄到您的平臺。
每當我改爲consent
或完全刪除它,它運作良好。
你能否請發表你正在使用的代碼? – 2013-04-07 14:31:04