本文整理汇总了Python中socialregistration.utils.OAuthClient.is_valid方法的典型用法代码示例。如果您正苦于以下问题:Python OAuthClient.is_valid方法的具体用法?Python OAuthClient.is_valid怎么用?Python OAuthClient.is_valid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类socialregistration.utils.OAuthClient
的用法示例。
在下文中一共展示了OAuthClient.is_valid方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: oauth_callback
# 需要导入模块: from socialregistration.utils import OAuthClient [as 别名]
# 或者: from socialregistration.utils.OAuthClient import is_valid [as 别名]
def oauth_callback(request, consumer_key=None, secret_key=None,
request_token_url=None, access_token_url=None, authorization_url=None,
callback_url=None, template='socialregistration/oauthcallback.html',
extra_context=dict(), parameters=None):
"""
View to handle final steps of OAuth based authentication where the user
gets redirected back to from the service provider
"""
client = OAuthClient(request, consumer_key, secret_key, request_token_url,
access_token_url, authorization_url, callback_url, parameters)
# the user has denied us - throw that in messages to be displayed and send them back where they came from
if 'denied' in request.GET:
messages.info(request, "You must authorize the application in order to link your account.")
try:
redirect = request.META['HTTP_REFERER'] # send them where they came from
except KeyError:
redirect = _get_next(request) # and fall back to what the view would use otherwise
return HttpResponseRedirect(redirect)
extra_context.update(dict(oauth_client=client))
if not client.is_valid():
return render_to_response(
template, extra_context, context_instance=RequestContext(request)
)
# We're redirecting to the setup view for this oauth service
return HttpResponseRedirect(reverse(client.callback_url))
示例2: oauth_callback
# 需要导入模块: from socialregistration.utils import OAuthClient [as 别名]
# 或者: from socialregistration.utils.OAuthClient import is_valid [as 别名]
def oauth_callback(request, consumer_key=None, secret_key=None,
request_token_url=None, access_token_url=None, authorization_url=None,
callback_url=None, template='socialregistration/oauthcallback.html',
extra_context=dict(), parameters=None):
"""
View to handle final steps of OAuth based authentication where the user
gets redirected back to from the service provider
"""
client = OAuthClient(request, consumer_key, secret_key, request_token_url,
access_token_url, authorization_url, callback_url, parameters)
extra_context.update(dict(oauth_client=client))
if not client.is_valid():
# Here we get when the oauth client is not valid
logging.error('client is invalid')
logging.info('parameters present: %s', str(parameters))
try:
logging.error('request token %s', client._get_rt_from_session())
logging.error('access token %s', client._get_access_token())
except:
pass
for error in client.errors:
logging.error('errors in client: %s', str(error))
return render_to_response(
template, extra_context, context_instance=RequestContext(request)
)
# We're redirecting to the setup view for this oauth service
return HttpResponseRedirect(reverse(client.callback_url))
示例3: oauth_callback
# 需要导入模块: from socialregistration.utils import OAuthClient [as 别名]
# 或者: from socialregistration.utils.OAuthClient import is_valid [as 别名]
def oauth_callback(
request,
consumer_key=None,
secret_key=None,
request_token_url=None,
access_token_url=None,
authorization_url=None,
callback_url=None,
template="socialregistration/oauthcallback.html",
extra_context=dict(),
parameters=None,
):
"""
View to handle final steps of OAuth based authentication where the user
gets redirected back to from the service provider
"""
client = OAuthClient(
request,
consumer_key,
secret_key,
request_token_url,
access_token_url,
authorization_url,
callback_url,
parameters,
)
extra_context.update(dict(oauth_client=client))
if not client.is_valid():
return render_to_response(template, extra_context, context_instance=RequestContext(request))
# We're redirecting to the setup view for this oauth service
return HttpResponseRedirect(reverse(client.callback_url))