Facebook Login is not working (Sorry, something went wrong)

I thought this is Facebook's issue, but it worked well when I used the Facebook SDK directly. It seems like there is something wrong with hello.js.
(Even the example from https://adodson.com/hello.js/ is not working)
I'll try to figure out what is wrong..
It is something related to the "state" parameter.
Any idea how to fix it?
@MrSwitch Can help? Thanks.
@omeraplak did you check if there's side effect anywhere else after deleting the state ? How did you test it ?
Having an url-encoded { (%7B) in the first position of state is the issue.
We have worked it around internally by prepending a space (%20) to the state but this isn't necessarily the best option for hello.js.
@przemek-pokrywka Can you share full solution?
@omeraplak Unfortunately I cannot, also it wouldn't be helpful since it was in custom code outside of hellojs, but my point is as follows:
- when you construct a URL which points to Facebook, make sure, that
statedoes not start with the{(%7B) character. For example you can prepend a space (%20) to thestateparameter value. Otherwise you will get HTTP 500 with the error page.
@przemek-pokrywka Where we need to add space the code
@sqlProvider In the URL which points to Facebook (see the screenshot from the issue description): https://www.facebook.com/dialog/oauth?clientid=XXXsomeotherstuffXXX&state=HERE
The HERE must not start with { (%7B).
Where exactly should be the hellojs be fixed (and should it be fixed in that way at all) I don't know, sorry.
Just like what @przemek-pokrywka said, the issue is with the constructed/generated facebook URL by hello.js. %7B should be replaced with space (%20) or & (%26%).
Just keep in mind, that the { character exists there because it starts a JSON object used internally by hellojs. Replacing that character would obviously break that JSON object. For this very reason we were not replacing it, but prepending a space character, which we then remove in other place.
@albertonaperijr @przemek-pokrywka okay i understand, i use with popup mode.
My url;
I changing { to " "
My final url on popup url is;
https://www.facebook.com/dialog/oauth/?client_id=XXXXXXX&response_type=token&redirect_uri=https://localhost/&state {"client_id":"XXXXXXX","network":"facebook","display":"popup","callback":"_hellojs_69q51g9e","state":"","redirect_uri":"https://localhost/","scope":"basic,email,birthday,user_photos"}&scope=public_profile,email,user_birthday,user_photos&display=popup
but doesn't work. Can help me?
Sorry, I don't have any universal solution for hellojs users, just one that works in a narrow context.
However I believe that the insight about Facebook being unable to handle state starting with { will help hellojs developers to fix hellojs.
@omeraplak I'm not sure if it would help you, but perhaps try URL-encoding the space (use + character instead).
Okay i share temp solution,
526 line adding,
p.qs.state = "+" + encodeURIComponent(JSON.stringify(p.qs.state));
and removing "+" on responseHandler function,
1444 line adding code,
location.hash = location.hash.replace("#state=+", "#state=")
Thanks @przemek-pokrywka
Facebook has acknowledged and is working on a fix: https://developers.facebook.com/bugs/1848797812109191/
Seems to be fixed since about 12 hours ago according to the FB link ☝️ . Works well for us either way!
@MrSwitch can we close this issue ?
I am still facing the same issue. Any fix for this.
This particular login issue can occur on Chrome debugging tools when using the mobile device manager.
https://stackoverflow.com/questions/33822789/facebook-oauth2-sorry-something-went-wrong/53662979#53662979
With that said I realize that the screenshot does not show the 'm.facebook.com' domain, but perhaps this was a variant on this issue and something has changed. Either way it's super frustrating and puzzled me for a while. Finally got around to some active detective work.