def revoke_access_token(self): # if there is only one osf user linked to this google drive user oauth, revoke the token, # otherwise, disconnect the osf user from the googledriveoauthsettings if len(self.googledriveusersettings__accessed) <= 1: client = GoogleAuthClient() try: client.revoke(self.access_token) except: # no need to fail, revoke is opportunistic pass # remove the object as its the last instance. GoogleDriveOAuthSettings.remove_one(self)