I'm developing an AngularJS application with google+ user authentication. I've taken the package angular-google-plus (an Angular module which handles the login with the Google+ API).
At it's heart, the login will use the gapi object:
gapi.auth.authorize(...)
Everything is working while the page doesn't refresh. For example, I can get the current user from the API with:
gapi.client.oauth2.userinfo.get().execute(function() { ... })
but again, the state wont be kept when I refresh the page.
What do I need to do in order to maintain the "Logged-In" state after the page is refreshed ? it seems the google api "forgets" the state.
I feel unfamiliar with your code... Is it really OAuth 2.0
?
I think you are talking about Google Sign-In JavaScript client because you are mentioning page refresh.
I believe that you cannot immediately get any information like gapi.client.oauth2.userinfo
because there is no code to wait for an instance to be initialized.
Do something like the following with then
:
gapi.auth2.init({client_id: "...", ...}).then(function(googleAuth) { // onInit
console.log(googleAuth.isSignedIn.get());
}, function() { // onError
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With