Reset the login cookie by API

安稳与你 提交于 2019-12-11 05:46:01

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!