本文整理汇总了Python中models.Token.create_token方法的典型用法代码示例。如果您正苦于以下问题:Python Token.create_token方法的具体用法?Python Token.create_token怎么用?Python Token.create_token使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Token
的用法示例。
在下文中一共展示了Token.create_token方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fetch_request_token
# 需要导入模块: from models import Token [as 别名]
# 或者: from models.Token import create_token [as 别名]
def fetch_request_token(self, oauth_consumer, oauth_callback):
logger.warning("!!! In MockOAuthDataStore.fetch_request_token args: %s"%locals())
if oauth_consumer.key != self.consumer.key:
raise OAuthError('Consumer key does not match.')
# OAuth 1.0a: if there is a callback, check its validity
callback = None
callback_confirmed = False
if oauth_callback:
if oauth_callback != OUT_OF_BAND:
if check_valid_callback(oauth_callback):
callback = oauth_callback
callback_confirmed = True
else:
raise oauth.OAuthError('Invalid callback URL.')
#not going to implement scope just yet-so just hard code this for now
resource = Resource.all().filter("name =","default")[0]
#try:
# resource = Resource.objects.get(name=self.scope)
#except:
# raise OAuthError('Resource %s does not exist.' % escape(self.scope))
self.request_token = Token.create_token(consumer=self.consumer,
token_type=Token.REQUEST,
timestamp=self.timestamp,
resource=resource,
callback=callback,
callback_confirmed=callback_confirmed)
return self.request_token
示例2: fetch_access_token
# 需要导入模块: from models import Token [as 别名]
# 或者: from models.Token import create_token [as 别名]
def fetch_access_token(self, oauth_consumer, oauth_token, oauth_verifier):
logger.warning("!!! IN MockOAuthDataStore.fetch_access_token args: %s"%locals())
if oauth_consumer.key_ == self.consumer.key_ \
and oauth_token.key_ == self.request_token.key_ \
and self.request_token.is_approved:
# OAuth 1.0a: if there is a callback confirmed, check the verifier
if (self.request_token.callback_confirmed \
and oauth_verifier == self.request_token.verifier) \
or not self.request_token.callback_confirmed:
self.access_token = Token.create_token(consumer=self.consumer,
token_type=Token.ACCESS,
timestamp=self.timestamp,
user=self.request_token.user)
return self.access_token
raise oauth.OAuthError('Consumer key or token key does not match. ' \
+'Make sure your request token is approved. ' \
+'Check your verifier too if you use OAuth 1.0a.')
示例3: fetch_request_token
# 需要导入模块: from models import Token [as 别名]
# 或者: from models.Token import create_token [as 别名]
def fetch_request_token(self, oauth_consumer, oauth_callback):
logger.warning("!!! In MockOAuthDataStore.fetch_request_token args: %s"%locals())
if oauth_consumer.key != self.consumer.key:
raise OAuthError('Consumer key does not match.')
# OAuth 1.0a: if there is a callback, check its validity
callback = None
callback_confirmed = False
if oauth_callback:
if oauth_callback != OUT_OF_BAND:
if check_valid_callback(oauth_callback):
callback = oauth_callback
callback_confirmed = True
else:
raise oauth.OAuthError('Invalid callback URL.')
self.request_token = Token.create_token(consumer=self.consumer,
token_type=Token.REQUEST,
timestamp=self.timestamp,
callback=callback,
callback_confirmed=callback_confirmed)
return self.request_token