所以我正在尝试使用angularJS在我的Web应用程序中实现google登录。弹出窗口打开以登录到我的Google帐户,或选择一个现有帐户,但登录后弹出窗口关闭,控制台中出现错误(popup_closed_by_user)
问题是我尝试过的100%一致。我已经尝试了铬和边缘,相同的结果。清除Cookie和缓存无济于事。 google + API和oauth已启用。原始网址已正确添加。 代码在angularJS中。
.directive('googleSignInButton',function(){
return {
scope:{
gClientId:'@',
callback: '&onSignIn'
},
template: '<button class="button button-block button-positive" ng-click="onSignInButtonClick()">Sign in with Google</button>',
controller: ['$scope','$attrs',function($scope, $attrs){
gapi.load('auth2', function() {
//load in the auth2 api's, without it gapi.auth2 will be undefined
gapi.auth2.init(
{
client_id: $attrs.gClientId
}
);
var GoogleAuth = gapi.auth2.getAuthInstance();//get's a GoogleAuth instance with your client-id, needs to be called after gapi.auth2.init
$scope.onSignInButtonClick=function(){//add a function to the controller so ng-click can bind to it
GoogleAuth.signIn().then(function(response){//request to sign in
$scope.callback({response:response});
});
};
});
}]
};
});