How to automatically log out from Google App Engin

2019-08-30 11:41发布

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']));
}

1条回答
smile是对你的礼貌
2楼-- · 2019-08-30 12:27

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.

查看更多
登录 后发表回答