Django-facebook登录重定向后url的更改
我正在做一个服务器端登录到facebook,成功登录后,用户会被重定向到正确的位置和所有内容,但url在最后有一些特殊的标志 这是我的登录功能:Django-facebook登录重定向后url的更改,facebook,python-2.7,facebook-login,django-1.4,Facebook,Python 2.7,Facebook Login,Django 1.4,我正在做一个服务器端登录到facebook,成功登录后,用户会被重定向到正确的位置和所有内容,但url在最后有一些特殊的标志 这是我的登录功能: def fb_login(request): args = dict(client_id=FACEBOOK_APP_ID, redirect_uri=request.build_absolute_uri()) # the user is already logged into facebook if 'code' in req
def fb_login(request):
args = dict(client_id=FACEBOOK_APP_ID, redirect_uri=request.build_absolute_uri())
# the user is already logged into facebook
if 'code' in request.GET:
args['client_secret'] = FACEBOOK_APP_SECRET
args['code'] = request.GET.get('code')
response = urlparse.parse_qs(urllib.urlopen("https://graph.facebook"
".com/oauth/access_token?" +
urllib.urlencode(args)).read())
# A short lived access token
access_token = response['access_token'][0]
# Extending the short lived access token
args['grant_type'] = "fb_exchange_token"
args['fb_exchange_token'] = access_token
reponse2 = urlparse.parse_qs(urllib.urlopen("https://graph.facebook"
".com/oauth/access_token?" +
urllib.urlencode(args)).read())
token = Token.objects.create(token=reponse2['access_token'][0],
expires_in=int(reponse2['expires'][0]))
# do stuff with the token
return HttpResponseRedirect(reverse('profile'))
# the user is not logged into facebook yet
else:
return HttpResponseRedirect("https://graph.facebook.com/oauth/authorize?" +
urllib.urlencode(args))
而不是此url:
http://localhost:8000/profile/
我明白了:
http://localhost:8000/profile/#_=_
什么会导致url像这样更改?出于某些安全原因,登录流会将此哈希附加到当前地址。@CBroe Hmmm..interest。这在twitter登录后不会发生。我应该担心吗?看起来它不会影响任何东西,页面上的所有其他链接都正常工作。