私は自分のウェブサイトでGoogleログインボタンを使用しています。私はユーザーを認証し、ユーザーのプロファイル情報を取得することができます。Google SignInボタンの使用中の追加の許可
私は今、私は彼がグーグルを使用して許可しながら、ユーザーの連絡先を読む必要があり、このIntegrating Google Sign-In into your web app
<div id="my-signin2" ></div>
gapi.signin2.render('my-signin2', {
'scope': 'profile email',
'width': 240,
'height': 50,
'longtitle': true,
'theme': 'light',
'onsuccess': this.onSuccess,
'onfailure': this.onFailure
});
onSuccess(googleUser) {
var id_token = googleUser.getAuthResponse().id_token;
var name = googleUser.getBasicProfile().getName());
var email = googleUser.getBasicProfile().getEmail());
var imageUrl = googleUser.getBasicProfile().getImageUrl());
}
onFailure(error) {
}
を追っています。私はすべてのものが正常に動作している範囲
https://www.googleapis.com/auth/contacts.readonly
gapi.signin2.render('my-signin2', {
'scope': 'profile email https://www.googleapis.com/auth/contacts.readonly',
'width': 240,
'height': 50,
'longtitle': true,
'theme': 'light',
'onsuccess': this.onSuccess,
'onfailure': this.onFailure
});
を追加した連絡先を取得するためのだから、
。 gmailを使用してユーザーが承認した後、ユーザーに許可画面が表示され、許可が求められます。
しかし、ユーザーがアクセス許可を拒否した場合でも、ユーザーはログに記録されません。私は彼が拒否したとしても、私は彼の連絡先を取得しない場合は、そのユーザーにログインしたい。
私は(ユーザーが電子メールを許可した後)についてrequesting additional scopes.
var options = new gapi.auth2.SigninOptionsBuilder(
{'scope': 'https://www.googleapis.com/auth/contacts.readonly'});
googleUser = auth2.currentUser.get();
googleUser.grant(options).then(
function(success){
console.log(JSON.stringify({message: "success", value: success}));
},
function(fail){
alert(JSON.stringify({message: "fail", value: fail}));
});
私がするonSuccessに、この後に使用する場合、それはいつもの方法を失敗することになり読みました。このthread
での議論を1として "popup_closed_by_user"