classOAuth:''' OAuth Args: mail (str): Mail address '''def__init__(self,mail:str)->None:self.mail=maildefget(self)->Optional[dict[str,Any]]:''' Get data Returns: Return the data by the mail. '''returnOAuthDB().find_one({'_id':self.mail})@staticmethoddefadd(mail:str,data:Optional[dict[str,Any]]=None,token:Optional[Credentials]=None)->None:''' add data, token Args: mail (str): Mail address. data (dict): The data from the oauth response. token (dict): OAuth token. '''ifany((data,token)):oauth_db=OAuthDB()ifdataisnotNone:oauth_db.add_data(mail=mail,data=data)iftokenisnotNone:oauth_db.add_token(mail=mail,credentials=token)@staticmethoddefowner(mail:str)->Optional[str]:''' return the owner Args: mail (str): Mail address. Raises: Exception: No oauth data of `{mail}`. '''data=OAuthDB().find_one({'_id':mail},{'owner':1})ifnotdata:raiseException(f'No oauth data of `{mail}`')returndata.get('owner')
@staticmethoddefadd(mail:str,data:Optional[dict[str,Any]]=None,token:Optional[Credentials]=None)->None:''' add data, token Args: mail (str): Mail address. data (dict): The data from the oauth response. token (dict): OAuth token. '''ifany((data,token)):oauth_db=OAuthDB()ifdataisnotNone:oauth_db.add_data(mail=mail,data=data)iftokenisnotNone:oauth_db.add_token(mail=mail,credentials=token)
@staticmethoddefowner(mail:str)->Optional[str]:''' return the owner Args: mail (str): Mail address. Raises: Exception: No oauth data of `{mail}`. '''data=OAuthDB().find_one({'_id':mail},{'owner':1})ifnotdata:raiseException(f'No oauth data of `{mail}`')returndata.get('owner')