parse-server icon indicating copy to clipboard operation
parse-server copied to clipboard

"Facebook auth is invalid for this user." after trying to log in after app has been deleted.

Open astanton opened this issue 10 years ago • 17 comments

When logging into our app we're using the PFFacebookUtils method PFFacebookUtils.logInInBackgroundWithReadPermissions(self.permissions, block: {}) and that is working fine. The first time that is ran, the callback has the user.isNew flag set to true and we go one path.

However I'm trying to test out the workflow where the user deletes the app from their phone and Facebook account.

In this instance when I hit the other path where user.isNew is false in the callback, the new time I go to save the user after making updates to it, I get the error Facebook auth is invalid for this user..

Is this by design and is there something I have to do to get this workflow working? Or is this a bug?

astanton avatar Apr 11 '16 20:04 astanton

Sorry for the late response, I guess this issue got missed somewhere. Can you provide some logs from your server, or a snippet of code that consistently reproduces the issue?

drew-gross avatar May 13 '16 20:05 drew-gross

@astanton I'm actually facing the same issue. And this issue also happens when a user changes his/hers facebook password and try to relogin in app.

@drew-gross To reproduce, simply:

  1. Login with a user through ParseFacebook login ([PFFacebookUtils logInInBackgroundWithReadPermissions:..]-iOS, ParseFacebookUtils.logInWithReadPermissionsInBackground-Android).
  2. Change password of that Facebook Account or remove app from Facebook->Settings->App Settings.
  3. Refresh User in the app (FBSDKAccessToken refreshCurrentAccessToken), or just re-login to the app through Facebook.
  4. Try to do something with that user and Facebook or parse-server (use a cloud function, or try to request that user's data from FB etc).

You will get an error saying something along the lines of "Please log into this app again to reconnect to your Facebook account.". And this persists even if the user logs out of the Facebook in the app, and reconnects.

If you change parse initialization from parse-server to Parse, the issue does not persist. Hence why it must be something to do with the Parse-Server (maybe not refreshing saved access token of user and giving it back after a successful ParseFacebook login).

Any help would be appreciated.

Thanks

PetrosCharalambous avatar Jun 15 '16 12:06 PetrosCharalambous

I also have this issue and @PetrosCharalambous describes it perfectly.

rsweny avatar Jun 23 '16 19:06 rsweny

Was this fixed in 2.2.16 ? I still see the problem, it throws com.parse.ParseRequest$ParseRequestException: Facebook auth is invalid for this user when ParseFacebookUtils.logInWithReadPermissionsInBackground is called. It does work when hitting Parse.com

rsweny avatar Jul 11 '16 20:07 rsweny

I am getting this same issue with Parse iOS SDK v1.14.2.

After making this call: PFFacebookUtils.logInInBackground(withReadPermissions: ["public_profile", "email", "user_friends"], block: { (user: PFUser?, error: Error?) ->

I get this error from Parse: [Error]: Facebook auth is invalid for this user. (Code: 101, Version: 1.14.2) Error Domain=Parse Code=101 "Facebook auth is invalid for this user." UserInfo={code=101, error=Facebook auth is invalid for this user., temporary=0, NSLocalizedDescription=Facebook auth is invalid for this user.}

(I am running this on a Facebook test user)

vandutran avatar Dec 28 '16 23:12 vandutran

I still am getting the issue. Is it a Facebook SDK issue, a parse-server issue, or a parse iOS issue? It's hard to figure out but very painful - especially because it's interfering with stripe payments too.

santiagoprieto avatar Feb 25 '17 19:02 santiagoprieto

Can you provide the logs when running with VERBOSE=1

flovilmart avatar Feb 25 '17 20:02 flovilmart

Hi! Yes, thanks for your quick reply 👍. Below is what appears in my logs. I don't know if it's VERBOSE=1 but I hope it helps :)

URL : https://test.punkpost.rocks/parse/batch Method : Optional("POST") Headers : Optional(["Content-Type": "application/json; charset=utf-8", "X-Parse-Installation-Id": "25629726-2c61-48ac-a37c-d109a54dfe97", "X-Parse-Session-Token": "r:f8abbae63e0d41a32941cb854dad3bf7"]) Request Body : Optional({"requests":[{"path":"/parse/classes/Contacts/1djy0WrMgP","method":"PUT","body":{}}]}) URL : https://test.punkpost.rocks/parse/batch Status Code : Optional(200) Headers : Optional([AnyHashable("Content-Type"): application/json; charset=utf-8, AnyHashable("Access-Control-Allow-Methods"): GET,PUT,POST,DELETE,OPTIONS, AnyHashable("Content-Length"): 74, AnyHashable("Connection"): keep-alive, AnyHashable("X-Powered-By"): Express, AnyHashable("Access-Control-Allow-Origin"): *, AnyHashable("Access-Control-Allow-Headers"): X-Parse-Master-Key, X-Parse-REST-API-Key, X-Parse-Javascript-Key, X-Parse-Application-Id, X-Parse-Client-Version, X-Parse-Session-Token, X-Requested-With, X-Parse-Revocable-Session, Content-Type, AnyHashable("Server"): nginx/1.8.1, AnyHashable("Date"): Sat, 25 Feb 2017 20:25:02 GMT, AnyHashable("Content-Encoding"): gzip]) Response Body : [{"success":{"updatedAt":"2017-02-25T20:25:02.190Z"}}] URL : https://test.punkpost.rocks/parse/batch Method : Optional("POST") Headers : Optional(["Content-Type": "application/json; charset=utf-8", "X-Parse-Installation-Id": "25629726-2c61-48ac-a37c-d109a54dfe97", "X-Parse-Session-Token": "r:f8abbae63e0d41a32941cb854dad3bf7"]) Request Body : Optional({"requests":[{"path":"/parse/classes/Contacts/1djy0WrMgP","method":"PUT","body":{}}]}) URL : https://test.punkpost.rocks/parse/classes/_User/Qds1qXvJPB Method : Optional("PUT") Headers : Optional(["Content-Type": "application/json; charset=utf-8", "X-Parse-Installation-Id": "25629726-2c61-48ac-a37c-d109a54dfe97", "X-Parse-Session-Token": "r:f8abbae63e0d41a32941cb854dad3bf7"]) Request Body : Optional({"posts":{"objects":[{"__type":"Pointer","className":"Post","objectId":"fxeMjG1Aqg"}],"__op":"AddRelation"},"lastSent":{"__type":"Date","iso":"2017-02-25T20:25:01.635Z"},"cardsOrdered":{"amount":1,"__op":"Increment"},"authData":{"facebook":{"id":"10154051162608313","expiration_date":"2016-11-24T01:00:00.540Z","access_token":"EAAFpaFfJkZCkBAA2DrkiWrRmXaeqBFsLdrUYI580oVhVXvbZAxeF6wTQkYvk2qbnhn20kqAZBKtvv2Iqt4mmdAA6zRoySPLUAv2IIe6l9ug9d5TwZBasMtfcFuzZBWMkmnWMTLELnVirdnHbmfVBJ7JeavtoGShtxYZBBOSrG9HwZDZD"}}}) URL : https://test.punkpost.rocks/parse/batch Status Code : Optional(200) Headers : Optional([AnyHashable("Content-Type"): application/json; charset=utf-8, AnyHashable("Access-Control-Allow-Methods"): GET,PUT,POST,DELETE,OPTIONS, AnyHashable("Content-Length"): 74, AnyHashable("Connection"): keep-alive, AnyHashable("X-Powered-By"): Express, AnyHashable("Access-Control-Allow-Origin"): *, AnyHashable("Access-Control-Allow-Headers"): X-Parse-Master-Key, X-Parse-REST-API-Key, X-Parse-Javascript-Key, X-Parse-Application-Id, X-Parse-Client-Version, X-Parse-Session-Token, X-Requested-With, X-Parse-Revocable-Session, Content-Type, AnyHashable("Server"): nginx/1.8.1, AnyHashable("Date"): Sat, 25 Feb 2017 20:25:02 GMT, AnyHashable("Content-Encoding"): gzip]) Response Body : [{"success":{"updatedAt":"2017-02-25T20:25:02.402Z"}}] URL : https://test.punkpost.rocks/parse/classes/Post/fxeMjG1Aqg Method : Optional("PUT") Headers : Optional(["Content-Type": "application/json; charset=utf-8", "X-Parse-Installation-Id": "25629726-2c61-48ac-a37c-d109a54dfe97", "X-Parse-Session-Token": "r:f8abbae63e0d41a32941cb854dad3bf7"]) Request Body : Optional({"recipients":{"objects":[{"__type":"Pointer","className":"Contacts","objectId":"vwwIjsaRkW"}],"__op":"AddRelation"}}) 2017-02-25 12:25:02.669062 Punkpost[9084:3511228] [Error]: Facebook auth is invalid for this user. (Code: 101, Version: 1.14.2) URL : https://test.punkpost.rocks/parse/classes/_User/Qds1qXvJPB Status Code : Optional(404) Headers : Optional([AnyHashable("Content-Type"): application/json; charset=utf-8, AnyHashable("Access-Control-Allow-Methods"): GET,PUT,POST,DELETE,OPTIONS, AnyHashable("Content-Length"): 81, AnyHashable("Connection"): keep-alive, AnyHashable("X-Powered-By"): Express, AnyHashable("Access-Control-Allow-Origin"): *, AnyHashable("Access-Control-Allow-Headers"): X-Parse-Master-Key, X-Parse-REST-API-Key, X-Parse-Javascript-Key, X-Parse-Application-Id, X-Parse-Client-Version, X-Parse-Session-Token, X-Requested-With, X-Parse-Revocable-Session, Content-Type, AnyHashable("Server"): nginx/1.8.1, AnyHashable("Date"): Sat, 25 Feb 2017 20:25:02 GMT, AnyHashable("Content-Encoding"): gzip]) Response Body : {"code":101,"error":"Facebook auth is invalid for this user."} URL : https://test.punkpost.rocks/parse/classes/Post/fxeMjG1Aqg Status Code : Optional(200) Headers : Optional([AnyHashable("Content-Type"): application/json; charset=utf-8, AnyHashable("Access-Control-Allow-Methods"): GET,PUT,POST,DELETE,OPTIONS, AnyHashable("Content-Length"): 60, AnyHashable("Connection"): keep-alive, AnyHashable("X-Powered-By"): Express, AnyHashable("Access-Control-Allow-Origin"): *, AnyHashable("Access-Control-Allow-Headers"): X-Parse-Master-Key, X-Parse-REST-API-Key, X-Parse-Javascript-Key, X-Parse-Application-Id, X-Parse-Client-Version, X-Parse-Session-Token, X-Requested-With, X-Parse-Revocable-Session, Content-Type, AnyHashable("Server"): nginx/1.8.1, AnyHashable("Date"): Sat, 25 Feb 2017 20:25:02 GMT, AnyHashable("Content-Encoding"): gzip]) Response Body : {"updatedAt":"2017-02-25T20:25:02.696Z"} URL : https://test.punkpost.rocks/parse/functions/confirmCardSentMail Method : Optional("POST") Headers : Optional(["Content-Type": "application/json; charset=utf-8", "X-Parse-Installation-Id": "25629726-2c61-48ac-a37c-d109a54dfe97", "X-Parse-Session-Token": "r:f8abbae63e0d41a32941cb854dad3bf7"]) Request Body : Optional({"email":"[email protected]","objectId":"fxeMjG1Aqg"})

santiagoprieto avatar Feb 25 '17 20:02 santiagoprieto

I never ended up figuring this out on my end but we've long since ripped out Parse completely and just set up a node.js server as our backend.

astanton avatar Feb 25 '17 20:02 astanton

Hey @flovilmart any tips or tricks on this issue? I'd rather not rip out parse like @astanton :(

santiagoprieto avatar Mar 01 '17 20:03 santiagoprieto

@santiagoprieto I meant the server logs not the client logs

flovilmart avatar Mar 01 '17 20:03 flovilmart

Any news on this?

kelset avatar Apr 04 '17 10:04 kelset

another clue is when this happens to a user even the parse dashboard can't edit the user, it gives the same "Facebook auth is invalid for this user" error.

rsweny avatar Apr 21 '17 21:04 rsweny

I'll have a look then

flovilmart avatar Apr 21 '17 22:04 flovilmart

My setup is on heroku, with a pipeline. Started seeing this issue on production but not staging. Realized that production was one commit behind- very minor, nothing that should affect this. Promoting, and therefore restarting the server, seemingly fixed the issue.

Can't have stuff like this cropping up and then not really being able to fix it. Had a good run with Parse, but this will probably be my last app with parse server.

kajensen avatar Apr 23 '17 22:04 kajensen

@kajensen, while I understand your frustration, you're pinning it on an issue that was closed over a year ago. I am more than welcome to help you squash that issue, but without relevant logs in bug reports, I can't possibly understand what's wrong or why this issue is poping randomly.

What I suspect would be that the Facebook access token has expired and has been sent back to the server, therefore being invalid. This is perhaps an issue, i need to investigate more, and for that, logs when running with VERBOSE=1 and patience are required.

flovilmart avatar Apr 24 '17 00:04 flovilmart

@kelset I just provided a PR that will prevent revalidating authData when it's the same as the original data. This will most likely fix your issues with any 3rd party login services.

flovilmart avatar May 07 '17 14:05 flovilmart