Facebook callback has started appending #_=_ hash underscore to the Return URL
Does anyone know why? What is the solution?
|
|
via Facebook's Platform Updates:
To prevent this, set the redirect_uri in your login url request like so: (using Facebook php-sdk)
UPDATE The above is exactly as the documentation says to fix this. However, Facebook's documented solution does not work. Please consider leaving a comment on the Facebook Platform Updates blog post and follow this bug to get a better answer. Until then, add the following to your head tag to resolve this issue:
Or a more detailed alternative (thanks niftylettuce):
|
|||||||||||||||||||||
|
|
TL;DR
Full version with step by step instructions
Step by step:
Learn more about Learn more about |
|||||||||||||||||
|
|
if you want to remove the remaining "#" from the url
|
|||||||||||||||||
|
|
Not sure why they're doing this but, you could get around this by reseting the hash at the top of your page:
|
|||||||||
|
|
Facebook uses a frame and inside of it everything functions using AJAX communication. The biggest problem in this case is preserving the current page state. As far I understand, Facebook decided to use simulated anchors. This means if you clicked somewhere, they simulate that as an anchor inside of your page, and when the AJAX communication starts, they change the anchor bit of your URL as well. This solution helps you normally when you try to reload the page (not ENTER, press F5), because your browser sends the whole URL with anchors to the Facebook server. Therefore Facebook picks up the latest state (what you see) and you are then able to continue from there. When the callback returns with |
|||||||||
|
|
Major annoying, especially for apps that parse the URI and not just read the $_GET... Here's the hack I threw together... Enjoy!
|
|||||
|
|
You can also specify your own hash on the |
||||
|
|
|
This was implemented by Facebook by design for security reasons. Here's the explanation from Eric Osgood, a Facebook Team member:
Source: https://developers.facebook.com/bugs/318390728250352/ |
|||||
|
|
This can become kind of a serious issue if you're using a JS framework with hashbang (/#!/) URLs, e.g. Angular. Indeed, Angular will consider URLs with a non-hashbang fragment as invalid and throw an error :
If you're in such a case (and redirecting to your domain root), instead of doing :
Simply do :
|
|||||||||
|
|
I do not see how this problem is related to facebook AJAX. In fact the issue also occurs with JavaScript disabled and purely redirect based logins. An example exchange with facebook:
Happens only with Firefox for me too. |
||||
|
|
|
Adding this to my redirect page fixed the problem for me ...
|
|||||
|
|
With angular and angular ui router, you can fix this
|
|||||
|
|
A change was introduced recently in how Facebook handles session redirects. See "Change in Session Redirect Behavior" in this week's Operation Developer Love blog post for the announcement. |
|||||
|
|
For me, i make JavaScript redirection to another page to get rid of
|
|||||
|
|
A workaround that worked for me (using Backbone.js), was to add "#/" to the end of the redirect URL passed to Facebook. Facebook will keep the provided fragment, and not append its own "_=_". Upon return, Backbone will remove the "#/" part. For AngularJS, appending "#!" to the return URL should work. Note that the fragment identifier of the original URL is preserved on redirection (via HTTP status codes 300, 301, 302 and 303) by most browsers, unless the redirect URL also has a fragment identifier. This seems to be recommended behaviour. If you use a handler script that redirects the user elsewhere, you can append "#" to the redirect URL here to replace the fragment identifier with an empty string. |
|||
|
|
|
Using Angular 2 (RC5) and hash-based routes, I do this:
and
As far as I understand, the |
|||
|
|
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?