私たちは、GoogleがGoogle Appsアカウントに対してユーザーを認証してから、サーバーサイド検証とグループ検索を行うアプリケーションを提供しています。Google+ APIはアクセストークンを返しませんJavascript
Googleは認証に必要なaccess_token変数を保持するオブジェクトの名前を変更しました。ドキュメント(https://developers.google.com/identity/sign-in/web/reference#googleusergetbasicprofile)では、access_tokenはgetAuthResponse()メソッドから取得できますが、これを使用するとundefinedとして返されます。 console.log()の後にオブジェクトを調べると、access_token以外のすべてのフィールドが表示されます。私は、Googleが今後オブジェクトを再び変更し、私たちのアプリケーションなしで私たちを残してしまうのではないかと心配しています。 ここにコードがあります。
<head>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css">
<script src="https://apis.google.com/js/platform.js" async defer></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<meta name="google-signin-client_id" content="XXX.apps.googleusercontent.com">
<script>
//This happens after the user has authenticated with Google and has been passed
//back to the page
function onSignIn(googleUser) {
//Check to see whether the user is trying to sign out.
if (window.location.href.indexOf("signOut=1") !== -1) {
//Sign them out of the application.
signOut();
//redirect them to the same page, without the signOut query string so they can log back in if want
window.location.href='googlesigninform.html'
return false;
}
//Grab the token, access token and email.
var _id = googleUser.getAuthResponse().id_token; //This works
var _accessToken = googleUser.Ka.access_token; //This works but changed from googleUser.B.access_token
var profile = googleUser.getBasicProfile(); //Works
console.log(googleUser.access_token); //Undefined
console.log(googleUser.getAuthResponse().access_token);//Undefined
//Make a post request to the API
makePostRequest(_id, _accessToken, profile.getEmail());
}
access_token変数にアクセスする正しい方法は何ですか?
をaccess_tokenは、これは誰が返信しないことに疑問の愚かですか? –
昨夜もまたやりました。元のオブジェクトは再び名前を変更し、アプリケーションを壊しました。 –