问题
I wonder if there is any way to reset login cookies through the API. I know there is how to do this through the settings in admin.
回答1:
There's no direct API for resetting the login cookie. There's a workaround idea from this SO post. For more info, you can also check this Google thread.
回答2:
According to the G Suite forum, the only way to to do this is through a force password reset using Dito GAM on the user side.
Related question from SE:
Is it possible to reset sign-in cookies for all Gmail users in Google Admin?
回答3:
Toggling changePasswordAtNextLogin flag of a G Suite user logs him out of all devices.
Make the changePasswordAtNextLogin value to True and then False immediately. It is better than suspending the user as incoming mails will not get bounced.
Python example:
def changePasswordNextLogin(self,userEmail, status=True):
try:
reqBody = {"changePasswordAtNextLogin":status}
updateStatus = self.service.users().update(userKey=userEmail,body=reqBody).execute()
return True
except Exception, e:
logging.info("Exception change_passwordNextLogin = %s", e)
return False
def forceLogoutUser(self, userEmail):
self.changePasswordNextLogin(userEmail, True)
self.changePasswordNextLogin(userEmail, False)
return True
Call 'forceLogoutUser(userEmail)' when you want to log a user out of a all devices.
来源:https://stackoverflow.com/questions/52934817/reset-the-login-cookie-by-api