本文整理汇总了Python中models.Account.oauth_token_secret方法的典型用法代码示例。如果您正苦于以下问题:Python Account.oauth_token_secret方法的具体用法?Python Account.oauth_token_secret怎么用?Python Account.oauth_token_secret使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Account
的用法示例。
在下文中一共展示了Account.oauth_token_secret方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: callback
# 需要导入模块: from models import Account [as 别名]
# 或者: from models.Account import oauth_token_secret [as 别名]
def callback(request):
error = False
token = request.session.get('token', None)
if not token: error = True
token = oauth.OAuthToken.from_string(token)
if token.key != request.GET.get('oauth_token', 'no-token'): error = True
token = get_authorized_token(token)
# Actually login
obj = is_authorized(token)
if obj is None: error = True
if error:
return HttpResponseRedirect('/?msg=2')
username_twitter = obj['screen_name']
try: # Connexion au compte existant
u = User.objects.get(username=username_twitter)
user = Account.objects.get(user=u)
new_id = u.id
password_value = user.password
except User.DoesNotExist: # Creation du compte
password_value = makePassword(39,40)
new_user = User.objects.create_user(username=username_twitter, email='[email protected]', password=password_value)
new_user.first_name = obj['name']
new_user.is_staff = False
new_user.is_superuser = False
new_user.save()
usermod = new_user
new_id = new_user.id
user = Account(user=new_user)
user.password = password_value
user.oauth_token = token.key
user.oauth_token_secret = token.secret
user.url = obj['url']
user.location = obj['location']
user.description = obj['description']
user.avatar_url = obj['profile_image_url']
user.save()
userco = authenticate(username=username_twitter, password=password_value)
if userco is not None:
login(request, userco)
return HttpResponseRedirect('/?msg=2')
else:
return HttpResponseRedirect('/?msg=1')