本文整理汇总了Python中socialregistration.utils.OpenID.complete方法的典型用法代码示例。如果您正苦于以下问题:Python OpenID.complete方法的具体用法?Python OpenID.complete怎么用?Python OpenID.complete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类socialregistration.utils.OpenID
的用法示例。
在下文中一共展示了OpenID.complete方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: openid_callback
# 需要导入模块: from socialregistration.utils import OpenID [as 别名]
# 或者: from socialregistration.utils.OpenID import complete [as 别名]
def openid_callback(request, template='socialregistration/openid.html',
extra_context=dict(), account_inactive_template='socialregistration/account_inactive.html'):
"""
Catches the user when he's redirected back from the provider to our site
"""
client = OpenID(
request,
'http%s://%s%s' % (
_https(),
Site.objects.get_current().domain,
reverse('openid_callback')
),
request.session.get('openid_provider')
)
try:
request_args = util.normalDict(request.GET)
if request.method == 'POST':
request_args.update(util.normalDict(request.POST))
if request_args:
client.complete()
c = client.consumer
return_to = util.getViewURL(request, openid_callback)
response = client.result
ax_items = {}
if response.status == consumer.SUCCESS:
provider = request.session.get('openid_provider')
# Set the schema uri depending on who the openid provier is:
# request only name and email by default (same as Google schemas):
schemas = GoogleOpenIDSchemas()
if 'yahoo' in provider:
schemas = YahooOpenIDSchemas()
if 'myopenid' in provider:
schemas = MyOpenIDSchemas()
ax_response = {}
ax_response = ax.FetchResponse.fromSuccessResponse(response)
if ax_response:
# Name and email schemas are always set, but not others so check if they are not empty first:
birth_date = zip = gender = []
if schemas.birth_date_schema:
birth_date = ax_response.get(schemas.birth_date_schema)
if schemas.zip_schema:
zip = ax_response.get(schemas.zip_schema)
if schemas.gender_schema:
gender = ax_response.get(schemas.gender_schema)
ax_items = {
'display_name': ax_response.get(schemas.name_schema),
'email': ax_response.get(schemas.email_schema),
'birth_date': birth_date,
'home_zip': zip,
'gender': gender,
}
request.session['ax_items'] = ax_items
except Exception, e:
pass