Example #1
0
 def _get_refresh_token(self):
     """
     Generate an access token after refresh authorization.
     """
     access_token = AccessTokenDAO.get_token_by_refresh(self.refresh_token)
     access_token = AccessTokenDAO.update(access_token.id)
     return access_token
Example #2
0
 def _get_authorization_code_token(self):
     """
     Generate an access token after authorization_code authorization.
     """
     access_token = AccessTokenDAO.create(self.client.id, self.user)
     CodeDAO.delete(self.code)
     return access_token
Example #3
0
 def _validate_refresh_token(self):
     """
     Validate a refresh token request.
     """
     if not self.refresh_token:
         raise InvalidRequest('未设置参数:refresh_token')
     self.access_token = AccessTokenDAO.get_token_by_refresh(self.refresh_token)
     if not self.access_token:
         raise InvalidRequest('No such refresh token: %s' % self.refresh_token)
     if not self.access_token.refreshable:
         raise InvalidGrant("Access token is not refreshable.")
Example #4
0
 def _get_password_token(self):
     """
     Generate an access token after password authorization.
     """
     access_token = None
     for i in range(3):
         access_token = AccessTokenDAO.create(self.client.id, self.user)
         if access_token:
             break
     if self.uuid and self.bundle_short_version and self.bundle_identifier:
         args = {'token_id': access_token.id, 'uuid': self.uuid, 'bundle_short_version': self.bundle_short_version,
                 'bundle_identifier': self.bundle_identifier}
         DeviceInfoDAO.create(args)
     return access_token