本文整理汇总了Python中sanction.client.Client.access_token方法的典型用法代码示例。如果您正苦于以下问题:Python Client.access_token方法的具体用法?Python Client.access_token怎么用?Python Client.access_token使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sanction.client.Client
的用法示例。
在下文中一共展示了Client.access_token方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_request
# 需要导入模块: from sanction.client import Client [as 别名]
# 或者: from sanction.client.Client import access_token [as 别名]
def process_request(self, request):
if not request.user.is_anonymous():
try:
provider = filter(lambda p: p["name"] == request.user.provider_key,
(settings.OAUTH2_PROVIDERS[k] for k in
settings.OAUTH2_PROVIDERS))[-1]
c = Client(token_endpoint=provider["token_endpoint"],
resource_endpoint=provider["resource_endpoint"],
auth_endpoint=provider["auth_endpoint"],
redirect_uri=provider.get("redirect_uri", None),
client_id=provider["client_id"],
client_secret=provider["client_secret"])
c.access_token = request.user.access_token
c.expires = request.user.expires
setattr(request.user, "resource", c)
# play nice with other authentication backends
except IndexError:
raise KeyError("Provider %s doesn't exist" %
request.user.provider_key)
except AttributeError:
# current user isn't a django_sanction user
pass
示例2: resource
# 需要导入模块: from sanction.client import Client [as 别名]
# 或者: from sanction.client.Client import access_token [as 别名]
def resource(self):
provider = settings.SANCTION_PROVIDERS[self.name]
c = SanctionClient(auth_endpoint=provider['auth_endpoint'],
token_endpoint=provider['token_endpoint'],
resource_endpoint=provider['resource_endpoint'],
client_id=provider['client_id'],
client_secret=provider['client_secret'])
c.refresh_token = self.refresh_token
c.access_token = self.access_token
c.token_expires = self.token_expires
return c