本文整理汇总了Python中openid.consumer.consumer.Consumer.redirectURL方法的典型用法代码示例。如果您正苦于以下问题:Python Consumer.redirectURL方法的具体用法?Python Consumer.redirectURL怎么用?Python Consumer.redirectURL使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类openid.consumer.consumer.Consumer
的用法示例。
在下文中一共展示了Consumer.redirectURL方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from openid.consumer.consumer import Consumer [as 别名]
# 或者: from openid.consumer.consumer.Consumer import redirectURL [as 别名]
def get(self):
federated_id = self.request.args.get(AUTH_REQUEST_FIELD)
if not federated_id:
response = Response("missing %s field\n" % AUTH_REQUEST_FIELD)
# Since we only care about Ajax requests we don't have to do
# anything more informative than a 409.
response.status_code = 409
return self.respond(response)
session = self.environ.get(BEAKER_ENV_KEY)
try:
auth_request = Consumer(session, aeoid_store.AppEngineStore()).begin(federated_id)
except DiscoveryFailure:
response = Response("discovery failure\n")
# Since we only care about Ajax requests we don't have to do
# anything more informative than a 409.
response.status_code = 409
return self.respond(response)
# If this raises a different exception it will be caught by the fwerks dispatcher.
# TODO: We need a nicer way of handling exceptions here.
host_url = self.request.host_url
cont = self.request.args.get("continuation", "/")
return_to = urlparse.urljoin(host_url, cont)
redirect_url = auth_request.redirectURL(host_url, return_to)
# The Ajax request wants the redirect url as plain text, not an actual
# HTTP redirect.
response = self.respond(Response(redirect_url))
session.save()
return response