#NEWLINE# @ gen . coroutine #NEWLINE# def CreateAccessTokenURL( self , client , group_id , use_short_token , **kwargs ) : #NEWLINE# #INDENT# 'Creates a verification access token.\n\n    The token is associated with a ShortURL that will be sent to the identity email address\n    or phone number. Following the URL will reveal the access token. The user that presents\n    the correct token to Identity.VerifyAccessToken is assumed to be in control of that email\n    address or SMS number.\n\n    Returns the ShortURL that was generated.\n    ' #NEWLINE# ( identity_type , value ) = Identity . SplitKey ( self . key ) #NEWLINE# ( num_digits , good_for ) = Identity . GetAccessTokenSettings ( identity_type , use_short_token ) #NEWLINE# now = util . GetCurrentTimestamp ( ) #NEWLINE# access_token = None #NEWLINE# if ( ( self . authority == 'Viewfinder' ) and ( now < self . expires ) and ( self . access_token is not None ) and ( len ( self . access_token ) == num_digits ) ) : #NEWLINE# #INDENT# access_token = self . access_token #NEWLINE# #UNINDENT# if ( access_token is None ) : #NEWLINE# #INDENT# format = ( ( '%0' + str ( num_digits ) ) + 'd' ) #NEWLINE# access_token = ( format % random . randint ( 0 , ( ( 10 ** num_digits ) - 1 ) ) ) #NEWLINE# #UNINDENT# expires = ( now + good_for ) #NEWLINE# short_url = ( yield ShortURL . Create ( client , client , timestamp = now , expires = expires , access_token = access_token , ** kwargs ) ) #NEWLINE# self . authority = 'Viewfinder' #NEWLINE# self . access_token = access_token #NEWLINE# self . expires = expires #NEWLINE# self . json_attrs = { #NEWLINE# #INDENT# 'group_id' : short_url . group_id , #NEWLINE# 'random_key' : short_url . random_key , #NEWLINE# #UNINDENT# } #NEWLINE# ( yield gen . Task ( self . Update , client ) ) #NEWLINE# guess_id = self . _ConstructAccessTokenGuessId ( identity_type , self . user_id ) #NEWLINE# if ( not ( yield Guess . CheckGuessLimit ( client , guess_id , Identity . _MAX_GUESSES ) ) ) : #NEWLINE# #INDENT# raise TooManyGuessesError ( TOO_MANY_GUESSES_ERROR ) #NEWLINE# #UNINDENT# raise gen . Return ( short_url )