#NEWLINE# def add_code( self , client_id , user_id , lifetime ) : #NEWLINE# #INDENT# 'Adds a temporary authorization code to the database. It takes 3\n        arguments:\n        * The client application ID\n        * The user ID who wants to authenticate\n        * The lifetime of the temporary code\n        It returns the generated code\n        ' #NEWLINE# expires = add_seconds_to_date ( datetime . datetime . now ( ) , lifetime ) #NEWLINE# code = self . generate_hash_sha1 ( ) #NEWLINE# while self . get_refresh_token ( code ) : #NEWLINE# #INDENT# code = self . generate_hash_sha1 ( ) #NEWLINE# #UNINDENT# self . db . codes ( ( self . db . codes . code_id == code ) ) . update ( ** { #NEWLINE# #INDENT# 'client_id' : client_id , #NEWLINE# 'user_id' : user_id , #NEWLINE# 'expires' : code , #NEWLINE# #UNINDENT# } ) #NEWLINE# return code