I'm currently trying to create a website where a user can log in to their google + account. Most of them work. I force them to provide access to my site. They can log in, and I get their name and user ID, and I display content specific to their google account on my site.
When someone else wants to log in, and I try to "log out" of the site, google magazine still remembers that he just logged in, and after logging out he instantly runs the code to log in again. If I delete the SSID cookie from google, this will not do it, so I assume that where google stores the fact that I just logged in with x.
Is there a way when I log out so that google does not instantly log in with the same account, but asks for the google email address and password?
I feel like I'm missing something obvious here, but I can't figure out how to handle this.
The code I use to authenticate and retrieve data:
<button class ="btn btn-primary" id="authorize-button" style="visibility: hidden">Log in</button> <script> var clientId = ''; var apiKey = ''; var scopes = ''; function handleClientLoad() { gapi.client.setApiKey(apiKey); window.setTimeout(checkAuth,1); } function checkAuth() { //alert("authorize"); gapi.auth.authorize({client_id: clientId, scope: scopes, immediate: true}, handleAuthResult); } function handleAuthResult(authResult) { //alert("authorized"); //alert(authResult.access_token); var authorizeButton = document.getElementById('authorize-button'); if (authResult && !authResult.error) { authorizeButton.style.visibility = 'hidden'; makeApiCall(); } else { authorizeButton.style.visibility = ''; authorizeButton.onclick = handleAuthClick; } var token = document.createElement('h4'); token.appendChild(document.createTextNode(authResult.access_token)); document.getElementById('content').appendChild(token); } function handleAuthClick(event) { gapi.auth.authorize({client_id: clientId, scope: scopes, immediate: false}, handleAuthResult); return false; } var x; function makeApiCall() { //return; gapi.client.load('plus', 'v1', function() { var request = gapi.client.plus.people.get({ 'userId': 'me' }); request.execute(function(resp) { x = resp.id; var heading2 = document.createElement('h4'); var heading3 = document.createElement('h4'); heading3.appendChild(document.createTextNode(resp.displayName)); heading2.appendChild(document.createTextNode(resp.id)); document.getElementById('content2').appendChild(heading2); document.getElementById('content3').appendChild(heading3); $.post("token.php", {id: x}); }); }); }
source share