0

I've just added basic code from Google+ API docs.

    function onSignIn(googleUser) {
  var profile = googleUser.getBasicProfile();

  gapi.auth.checkSessionState({session_state: null}, function(isUserNotLoggedIn){
    if (isUserNotLoggedIn) {
        console.log('Not logged in');
      } else {
        console.log('Logged in');
      }
    });
  /*
  console.log('ID: ' + profile.getId()); // Do not send to your backend! Use an ID token instead.
  console.log('Name: ' + profile.getName());
  console.log('Image URL: ' + profile.getImageUrl());
  console.log('Email: ' + profile.getEmail());
  */

  var id_token = googleUser.getAuthResponse().id_token;
  //console.log("ID Token: " + id_token);
  $.post('login.asp', 'idtoken=' + id_token, function(data){
    //console.log('Passato a login.asp, idtoken=' + data);
  });
}

I see it's not the way to use it, but how can I check if a user is logged in or not, in order to let him access authenticated user features?

  • 2
    http://stackoverflow.com/questions/20922163/google-javascript-api-how-to-detect-user-sign-in-status – prasanth Nov 08 '16 at 11:15
  • Possible duplicate of [How to check whether a user has signed-in Google+?](http://stackoverflow.com/questions/22435869/how-to-check-whether-a-user-has-signed-in-google) – Rahul Khurana Nov 08 '16 at 11:26

0 Answers0