@gen.coroutine
  def CreateAccessTokenURL(self, client, group_id, use_short_token, **kwargs):
    identity_type, value = Identity.SplitKey(self.key)
    num_digits, good_for = Identity.GetAccessTokenSettings(identity_type, use_short_token)

    now = util.GetCurrentTimestamp()
    access_token = None
    if self.authority == 'Viewfinder' and now < self.expires and \
       self.access_token is not None and len(self.access_token) == num_digits:
      # Re-use the access token.
      access_token = self.access_token

    if access_token is None:
      # Generate new token, which is a random decimal number of 4 or 9 decimal digits.
      format = '%0' + str(num_digits) + 'd'
      access_token = format % random.randint(0, 10 ** num_digits - 1)

    # Create a ShortURL that contains the access token, along with caller-supplied parameters.
    expires = now + good_for
    short_url = yield ShortURL.Create(client,
                                      group_id,
                                      timestamp=now,
                                      expires=expires,
                                      access_token=access_token,
                                      **kwargs)

    # Update the identity to record the access token and short url information.
    self.authority = 'Viewfinder'
    self.access_token = access_token
    self.expires = expires
    self.json_attrs = {'group_id': short_url.group_id, 'random_key': short_url.random_key}
    yield gen.Task(self.Update, client)

    # Check whether user account is locked due to too many guesses.
    guess_id = self._ConstructAccessTokenGuessId(identity_type, self.user_id)
    if not (yield Guess.CheckGuessLimit(client, guess_id, Identity._MAX_GUESSES)):
      raise TooManyGuessesError(TOO_MANY_GUESSES_ERROR)

    raise gen.Return(short_url)
Creates a verification access token.
dataset/ETHPy150Open viewfinderco/viewfinder/backend/db/identity.py/Identity.CreateAccessTokenURL