How to get rid of the #
django-social-auth redirects me to /mypage#_=_
when using the the Facebook backend.
As I am working with jquery mobile on the front end, I can not accept that.
I found: https://developers.facebook.com/blog/post/552/ on the facebook developers site.
Change in Session Redirect Behavior
This week, we started adding a fragment #_=_ to the redirect_uri when this field is left blank. Please ensure that your app can handle this behavior.
So I tried settung SOCIAL_AUTH_LOGIN_REDIRECT_URL
in the django-social-auth settings to something 'none blank'. No luck
So, how to I get rid of the hash thing?
Thanks a lot!
那么,这可能不是确切的解决方案,但向您的头部添加以下脚本将有助于解决问题:
<script type="text/javascript">
if (window.location.hash == '#_=_') {
window.location.hash = '';
}
</script>
Looks like Facebook always appends the '#_=_' even if the redirect_uri is supplied. Since this behaviour is contrary to Facebook's blog post this functionality has been submitted to Facebook as a bug. Facebook has provided an official response to this bug claiming that appending the '#_=_' is a design feature that prevents a potential security flaw.
Facebook provides the following advice for dealing with the unwanted uri fragment, "If the aesthetics, or client-side behavior, of the resulting URL are of concern, it would be possible to use window.location.hash (or even a server-side redirect of your own) to remove the offending characters."
It appears that the javascript provided above is a valid solution, even if it is a bit hacky.
<script type="text/javascript">
if (window.location.href.indexOf('#') > -1) {
window.location.href = '/';
}
</script>
链接地址: http://www.djcxy.com/p/63286.html
上一篇: OAuth的
下一篇: 如何摆脱#