Итак, я пытаюсь внедрить логин Google в свое веб-приложение, используя angularJS. Открывается всплывающее окно для входа в мою учетную запись Google или для выбора одной из существующих учетных записей, но после входа всплывающее окно закрывается с ошибкой в консоли (popup_closed_by_user)
Проблема постоянна в 100% случаев, когда я пытался. Я попробовал это на хром и край, тот же результат. очистка куки и кеша не помогает. Google + API и oauth включен. URL-адрес источника добавлен правильно.
Код написан на английском языке.
.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});
});
};
});
}]
};
});