hello.js icon indicating copy to clipboard operation
hello.js copied to clipboard

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

Open velopert opened this issue 8 years ago • 19 comments

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..

velopert avatar Jun 08 '17 06:06 velopert

It is something related to the "state" parameter.

MetoooRepo avatar Jun 08 '17 08:06 MetoooRepo

Any idea how to fix it?

azayarni avatar Jun 08 '17 09:06 azayarni

@MrSwitch Can help? Thanks.

omeraplak avatar Jun 08 '17 09:06 omeraplak

@omeraplak did you check if there's side effect anywhere else after deleting the state ? How did you test it ?

proton1k avatar Jun 08 '17 10:06 proton1k

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 avatar Jun 08 '17 10:06 przemek-pokrywka

@przemek-pokrywka Can you share full solution?

omeraplak avatar Jun 08 '17 11:06 omeraplak

@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 state does not start with the { (%7B) character. For example you can prepend a space (%20) to the state parameter value. Otherwise you will get HTTP 500 with the error page.

przemek-pokrywka avatar Jun 08 '17 11:06 przemek-pokrywka

@przemek-pokrywka Where we need to add space the code

sqlProvider avatar Jun 08 '17 12:06 sqlProvider

@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.

przemek-pokrywka avatar Jun 08 '17 12:06 przemek-pokrywka

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%).

albertonaperijr avatar Jun 08 '17 12:06 albertonaperijr

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.

przemek-pokrywka avatar Jun 08 '17 12:06 przemek-pokrywka

@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?

omeraplak avatar Jun 08 '17 12:06 omeraplak

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).

przemek-pokrywka avatar Jun 08 '17 12:06 przemek-pokrywka

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

omeraplak avatar Jun 08 '17 12:06 omeraplak

Facebook has acknowledged and is working on a fix: https://developers.facebook.com/bugs/1848797812109191/

mririgoyen avatar Jun 08 '17 15:06 mririgoyen

Seems to be fixed since about 12 hours ago according to the FB link ☝️ . Works well for us either way!

JohanBengtsson avatar Jun 09 '17 10:06 JohanBengtsson

@MrSwitch can we close this issue ?

gtothesquare avatar Jun 15 '17 06:06 gtothesquare

I am still facing the same issue. Any fix for this.

zeeshanjan82 avatar Jun 28 '17 03:06 zeeshanjan82

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.

simeyla avatar Dec 07 '18 04:12 simeyla