This is my first time introducing Google Magazine as described here and here .
I am using HTML with Javascript.
The problem that needs to be solved is the following: how can I, after the first login to another page (for example, the landing page or portal that the user sees after logging in), check whether the user is logged in? Is there a service that I can call to check the userβs status entry with my application key or something similar? I assume that I will have to include the Google APIs on every page.
Login page code:
Script In the chapter (Code from the Google manual above):
<head> .... <script src="https://apis.google.com/js/platform.js" async defer></script> <script> function onSignIn(googleUser) { var profile = googleUser.getBasicProfile(); console.log('ID: ' + profile.getId()); console.log('Name: ' + profile.getName()); console.log('Image URL: ' + profile.getImageUrl()); console.log('Email: ' + profile.getEmail()); alert(profile.getName()); } function logout() { alert('logging out'); var auth2 = gapi.auth2.getAuthInstance(); auth2.signOut().then(function () { console.log('User signed out.'); }); } ... </head>
Code in body (1st line from the Google tutorial above, second line to run the exit test)
<body> ... <div class="g-signin2" data-onsuccess="onSignIn"></div> <div onmousedown="logout()">Logout</div> ... </body>
Is there a way to enable the Google API on another page and then call the login check function? Or another way to specifically indicate whether the user is registered or not?
source share