Kendi düğmemle akışta bir Google+ Oturumunu başlatmak için Google+ kılavuzunu takip etmeye çalışıyorum. geri arama işlevi ile ilgiliGoogle+ JavaScript ile giriş yap - hemen iki kere çağrıda bulunun
, gapi.auth.signIn referans diyor (tırnak):
"Oturum düğme de işlenen ve çağrılan genel ad alanında bir fonksiyon, giriş akışı tamamlandıktan sonra çağrılır. "
iletişim Google İşaret görünür oturum açmak için bana soran, ancak herhangi bir etkileşim iletişim ile yapılmadan önce geri arama, iki kere hemen denir. Her iki kez de benzer bir authResult, error = "anında_failed", error_subtype = "access_denied", status.signed_in = false
Niçin bu? yöntem değeri ise, durum değiştiğinde kullanıcı oturum açtıktan eğer
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv=Content-Type content="text/html; charset=utf-8" />
<script src="https://apis.google.com/js/client:platform.js?onload=googleRender" async defer></script>
</head>
<body>
<script>
function googleRender() { // executed when Google APIs finish loading
var googleSigninParams = {
'clientid' : '746836915266-a016a0hu45sfiouq7mqu5ps2fqsc20l4.apps.googleusercontent.com',
'cookiepolicy' : 'http://civoke.com',
'callback' : googleSigninCallback ,
'requestvisibleactions' : 'http://schema.org/AddAction',
'scope' : 'https://www.googleapis.com/auth/plus.login'
};
var googleSigninButton = document.getElementById('googleSigninButton');
googleSigninButton.addEventListener('click', function() {
gapi.auth.signIn(googleSigninParams);
});
}
function googleSigninCallback(authResult) {
console.log('googleSigninCallback called: ');
console.dir(authResult);
if (authResult['status']['signed_in']) {
document.getElementById('googleSigninButton').setAttribute('style', 'display: none'); // hide button
console.log('User is signed-in to Google');
} else {
console.log('User is NOT signed-in. Sign-in state: ' + authResult['error']);
}
}
</script>
<button id="googleSigninButton">Sign in with Google</button>
</body>
</html>
Her şeyden önce çalışıyor (teşekkürler). Bununla birlikte iki yorum: (1) 'PROMPT' değilken 'AUTO' yerine null olurum; (2) Bu durum neden iki kez ** olarak adlandırıldığını açıklamıyor, çünkü iki acil durum değişikliği yok ... –
Saçlarımı bu şekilde yırttım. Teşekkürler. – Keab42