Krish
Krish

Reputation: 421

How to automatically log out from Google App Engine application after logging out of Gmail

I'm using the App Engine Users Service API in PHP. My app requires authentication. The authentication for logging in is working fine, but when I logout of my Gmail account my app still shows that the user is logged in.

How do I make sure that the app also gets logged out the moment the Gmail account is logged out?

<?php
use google\appengine\api\users\User;
use google\appengine\api\users\UserService;
$user = UserService::getCurrentUser();

if ($user) 
{
    #perform action
}
else 
{
    header('Location: ' . UserService::createLoginURL($_SERVER['REQUEST_URI']));
}

Upvotes: 0

Views: 741

Answers (1)

Gwyn Howell
Gwyn Howell

Reputation: 5424

This is not possible.

When you use the Users Service API on App Engine, it authenticates you against your Google Account, and creates a 'session' on your App Engine server. This is all handled seamlessly by the API. After authentication, you are authenticated to your App Engine server independently. Therefore, logging out of your Google Account does not effect your App Engine session.

This does work the other way around however (ie logging out of your App Engine WILL log you out of your Google Account), as the action is triggered from your App Engine account.

Upvotes: 1

Related Questions