Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Facebook Login error: "[Error]: this auth is already used" #313

Closed
meilers opened this issue Feb 9, 2016 · 17 comments
Closed

Facebook Login error: "[Error]: this auth is already used" #313

meilers opened this issue Feb 9, 2016 · 17 comments
Labels
type:bug Impaired feature or lacking behavior that is likely assumed

Comments

@meilers
Copy link

meilers commented Feb 9, 2016

I'm using parse-server on AWS Elastic beanstalk with MongoLab and I'm getting this error when I login using Facebook:

[Error]: this auth is already used (Code: 208, Version: 1.12.0)

When I create the user via Facebook, everything is fine, but when I logout and then re-login again using Facebook I get the error.

Any ideas?

EDIT: It seems the user is created twice in the DB (one has the email, the other doesn't)
screen shot 2016-02-08 at 11 41 37 pm

EDIT2: This error was also happening on parse.com, but more as a warning: "[Error]: Another user is already linked to this facebook id. (Code: 208, Version: 1.10.0)". This happens if the user logs out - which creates a new anonymous user - and then relogs in with Facebook. But a duplicate user was never created on parse.com. It is however created here with Parse Server.

@natario1
Copy link

So you logout, create an anonymous user (which is the second entry there) and then link it with facebook? You should handle that yourself. However I agree that if it returns 208, parse-server should not save invalid auth data in the unlinkable user.

@drew-gross drew-gross added the type:bug Impaired feature or lacking behavior that is likely assumed label Feb 12, 2016
@drew-gross
Copy link
Contributor

This looks like bug potentially related to some recent changes in anonymous users. @steven-supersolid do you mind taking a look?

@steven-supersolid
Copy link
Contributor

I can take a look next week but looks like the issue was opened before the changes in #341 were merged.

@meilers would you mind clarifying the repro steps and version of parse-server this occurs in? I would like to narrow down the issue to Facebook login, anonymous login or Facebook linking. The error message seems to indicate this is an issue with linking though. If you post more of the authData screenshot then will be able to see if there is any anonymous authData,

@drew-gross
Copy link
Contributor

OK, if you think it's not related to your changes thats fine and we can do our own investigation.

@gfosco
Copy link
Contributor

gfosco commented Feb 20, 2016

Since a good number of things have changes in the user/auth space, please re-open if you're still experiencing this with 2.1.2.

@LBKevinSibue
Copy link

LBKevinSibue commented Sep 1, 2016

Hi everyone !
Yesterday I have updated my parse-server to the latest version and now when I call a CloudCode function from my app (iOS or Android) it's say to me there are an error.

So when I look at the log I can see that:

[31merror�[39m: Error generating response. ParseError { code: 208, message: 'this auth is already used' } code=208, message=this auth is already used

and that:

31merror�[39m: Error generating response. [TypeError: Cannot read property 'getSessionToken' of undefined]
�[31merror�[39m: Uncaught internal server error. [TypeError: Cannot read property 'getSessionToken' of undefined] TypeError: Cannot read property 'getSessionToken' of undefined
at /var/app/current/cloud/event.js:74:33
at /var/app/current/node_modules/parse-server/lib/triggers.js:249:26
at new Promise (/var/app/current/node_modules/parse-server/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:191:7)
at Object.maybeRunTrigger (/var/app/current/node_modules/parse-server/lib/triggers.js:228:10)
at RestWrite.runAfterTrigger (/var/app/current/node_modules/parse-server/lib/RestWrite.js:875:19)
at /var/app/current/node_modules/parse-server/lib/RestWrite.js:107:18
at run (/var/app/current/node_modules/parse-server/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:87:22)
at /var/app/current/node_modules/parse-server/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:100 :28
at flush (/var/app/current/node_modules/parse-server/node_modules/babel-polyfill/node_modules/core-js/modules/_microtask.js:18:9)
at nextTickCallbackWith0Args (node.js:420:9)
TypeError: Cannot read property 'getSessionToken' of undefined
at /var/app/current/cloud/event.js:74:33
at /var/app/current/node_modules/parse-server/lib/triggers.js:249:26
at new Promise (/var/app/current/node_modules/parse-server/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:191:7)
at Object.maybeRunTrigger (/var/app/current/node_modules/parse-server/lib/triggers.js:228:10)
at RestWrite.runAfterTrigger (/var/app/current/node_modules/parse-server/lib/RestWrite.js:875:19)
at /var/app/current/node_modules/parse-server/lib/RestWrite.js:107:18
at run (/var/app/current/node_modules/parse-server/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:87:22)
at /var/app/current/node_modules/parse-server/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:100 :28
at flush (/var/app/current/node_modules/parse-server/node_modules/babel-polyfill/node_modules/core-js/modules/_microtask.js:18:9)
at nextTickCallbackWith0Args (node.js:420:9)

Do you know what I need to do to correct that ?

@flovilmart
Copy link
Contributor

can you post the content of your cloud function? As well as the logs printed in the console with VERBOSE=1 environment variable set when you start your server?

@LBKevinSibue
Copy link

This error appear for example, when I call the cloud function "participateIntoEvent":

[31merror�[39m: Failed running cloud function participateIntoEvent for user XwDt4J1yXH with:
Input:
(if you want to search in the log).

It's seem like if the user is not log (still a anonymous user) and so the server can't get the session token, but I don't understand why.

Any idea ?

ParseServer - Error ParticipateIntoEvent.pdf
nodejs.pdf

@flovilmart
Copy link
Contributor

Can you isolate the relevant logs? Also, given the complexity/size of your function it's really tough to understand what's going on. You should probably try to reduce the size of that cloud function to isolate the failing part.

@LBKevinSibue
Copy link

LBKevinSibue commented Sep 5, 2016

Important logs are from my previous post:

[31merror [39m: Error Generating response. ParseError {code: 208 Message: 'this auth is already used'} = 208 code, message = this auth is already used

This appears each time a user.

And each call of function cloudcode using 'getSessionToken ()' I have this error:

31merror [39m: Error Generating response. [TypeError: Can not read property 'getSessionToken offi undefined]
[31merror [39m: Uncaught internal server error. [TypeError: Can not read property 'getSessionToken offi undefined] TypeError: Can not read property' getSessionToken offi undefined
at /var/app/current/cloud/event.js:74:33
at /var/app/current/node_modules/parse-server/lib/triggers.js:249:26
at New Promise (/var/app/current/node_modules/parse-server/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:191:7)
at Object.maybeRunTrigger (/var/app/current/node_modules/parse-server/lib/triggers.js:228:10)
at RestWrite.runAfterTrigger (/var/app/current/node_modules/parse-server/lib/RestWrite.js:875:19)
at /var/app/current/node_modules/parse-server/lib/RestWrite.js:107:18
Has run (/var/app/current/node_modules/parse-server/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:87:22)
/var/app/current/node_modules/parse-server/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:100 at 28
Has flush (/var/app/current/node_modules/parse-server/node_modules/babel-polyfill/node_modules/core-js/modules/_microtask.js:18:9)
at nextTickCallbackWith0Args (node.js: 420: 9)
TypeError: Can not read property 'getSessionToken offi undefined
at /var/app/current/cloud/event.js:74:33
at /var/app/current/node_modules/parse-server/lib/triggers.js:249:26
at New Promise (/var/app/current/node_modules/parse-server/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:191:7)
at Object.maybeRunTrigger (/var/app/current/node_modules/parse-server/lib/triggers.js:228:10)
at RestWrite.runAfterTrigger (/var/app/current/node_modules/parse-server/lib/RestWrite.js:875:19)
at /var/app/current/node_modules/parse-server/lib/RestWrite.js:107:18
Has run (/var/app/current/node_modules/parse-server/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:87:22)
/var/app/current/node_modules/parse-server/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:100 at 28
Has flush (/var/app/current/node_modules/parse-server/node_modules/babel-polyfill/node_modules/core-js/modules/_microtask.js:18:9)
at nextTickCallbackWith0Args (node.js: 420: 9)

I think the connection goes wrong (to view the error 'auth already used') but I do not know why.

@flovilmart
Copy link
Contributor

This error occurs when you're trying to save a user with auth data that doesn't belongs to him. I don't see any logs referring to that.

Also, the session token seems properly passed to the request to your cloud code function, therefore the user should be properly set in req.user. If req.user is set, you should not have the crash you're describing.

Also, because your function is so big, I can't possible write a test to make sure this can't reproduce in the future.

So please, try to isolate the error and the relevant logs, and when I say relevant it's the full trace that leads to the issue. If req.user is never set in your cloudCode, you should be able to write a simple cloud function that shows it.

@flovilmart
Copy link
Contributor

Also, in the first page of your logs, you can see a user getting fetched with the Facebook authData with the Facebook ID 891415857609934. Then a few pages later, another user (with a different objectId) is trying to link it's account with the same Facebook ID. That's why you see that 'auth already used' error. You should not try to link 2 accounts with the same authData. I'm not sure what you're doing in the client, probably log out, create a new anonymous user and then link to the same Facebook Account. So far it looks like a problem in the client, not the server

@LBKevinSibue
Copy link

Ok I'll look on my client. But I don't understand why before the update of my parse-server everything work fine and now each function of my cloud code return this error (I talk about the 'getSessionToken()' error)

@flovilmart
Copy link
Contributor

In order to debug that, can you write a simple cloud code function that returns this session token and provide the logs (and only the logs of that call) when you call it in place of this big function?

@LBKevinSibue
Copy link

The function which return the code:

Parse.Cloud.define("testSessionToken", function(request, response) {
console.log("testSessionToken --> STARTED");
var token = request.user.getSessionToken();
console.log(token);
});

And the log:

�[36mverbose�[39m: REQUEST for [POST] /parse/functions/testSessionToken: {} method=POST, url=/parse/functions/testSessionToken, host=test.superfc.io, x-real-ip=172.31.9.99, x-forwarded-for=82.122.57.77, 172.31.9.99, content-length=0, accept=/, accept-encoding=gzip, deflate, accept-language=fr-fr, user-agent=SFC/112 CFNetwork/758.5.3 Darwin/15.6.0, x-parse-app-build-version=112, x-parse-app-display-version=1.1.12, x-parse-application-id=29Ce3p2h29Aw9mlUvO8XkMZeXCLKl0SsJbhX8fhN, x-parse-client-key=yRdKparxomNECtqsXFkdHt9U0mKD7du48r9k1Emm, x-parse-client-version=i1.12.0, x-parse-installation-id=b584de1d-b9a1-470e-9292-8ac0a56644be, x-parse-os-version=9.3.3 (13G34), x-parse-session-token=r:7af6f0610e9a50134f01af1e644c098c, x-forwarded-port=443, x-forwarded-proto=https,
testSessionToken --> STARTED
r:7af6f0610e9a50134f01af1e644c098c

Here the log of my big function:

[31merror�[39m: Error generating response. [TypeError: Cannot read property 'getSessionToken' of undefined]
�[31merror�[39m: Uncaught internal server error. [TypeError: Cannot read property 'getSessionToken' of undefined] TypeError: Cannot read property 'getSessionToken' of undefined
at /var/app/current/cloud/event.js:74:33
at /var/app/current/node_modules/parse-server/lib/triggers.js:249:26
at new Promise (/var/app/current/node_modules/parse-server/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:191:7)
at Object.maybeRunTrigger (/var/app/current/node_modules/parse-server/lib/triggers.js:228:10)
at RestWrite.runAfterTrigger (/var/app/current/node_modules/parse-server/lib/RestWrite.js:875:19)
at /var/app/current/node_modules/parse-server/lib/RestWrite.js:107:18
at run (/var/app/current/node_modules/parse-server/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:87:22)
at /var/app/current/node_modules/parse-server/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:100:28
at flush (/var/app/current/node_modules/parse-server/node_modules/babel-polyfill/node_modules/core-js/modules/microtask.js:18:9)
at nextTickCallbackWith0Args (node.js:420:9)
TypeError: Cannot read property 'getSessionToken' of undefined
at /var/app/current/cloud/event.js:74:33
at /var/app/current/node_modules/parse-server/lib/triggers.js:249:26
at new Promise (/var/app/current/node_modules/parse-server/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:191:7)
at Object.maybeRunTrigger (/var/app/current/node_modules/parse-server/lib/triggers.js:228:10)
at RestWrite.runAfterTrigger (/var/app/current/node_modules/parse-server/lib/RestWrite.js:875:19)
at /var/app/current/node_modules/parse-server/lib/RestWrite.js:107:18
at run (/var/app/current/node_modules/parse-server/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:87:22)
at /var/app/current/node_modules/parse-server/node_modules/babel-polyfill/node_modules/core-js/modules/es6.promise.js:100:28
at flush (/var/app/current/node_modules/parse-server/node_modules/babel-polyfill/node_modules/core-js/modules/microtask.js:18:9)
at nextTickCallbackWith0Args (node.js:420:9)
�[31merror�[39m: Failed running cloud function participateIntoEvent for user XwDt4J1yXH with:
Input: {"eventId":"olbsj0M2CG","userId":"XwDt4J1yXH","languageCode":"fr","cloudCodeAPIVersion":309}
Error: {"code":141,"message":{"code":1}} functionName=participateIntoEvent, code=141, code=1, message=undefined, eventId=olbsj0M2CG, userId=XwDt4J1yXH, languageCode=fr, cloudCodeAPIVersion=309, user=XwDt4J1yXH
�[31merror�[39m: Error generating response. ParseError {
code: 141,
message: ParseError { code: 1, message: undefined } } code=141, code=1, message=undefined
[object Object]
�[36mverbose�[39m: REQUEST for [POST] /parse/functions/participateIntoEvent: {
"eventId": "olbsj0M2CG",
"userId": "XwDt4J1yXH",
"languageCode": "fr",
"cloudCodeAPIVersion": 309
} method=POST, url=/parse/functions/participateIntoEvent, host=test.superfc.io, x-real-ip=172.31.9.99, x-forwarded-for=82.122.57.77, 172.31.9.99, content-length=92, accept=
/
, accept-encoding=gzip, deflate, accept-language=fr-fr, content-type=application/json; charset=utf-8, user-agent=SFC/112 CFNetwork/758.5.3 Darwin/15.6.0, x-parse-app-build-version=112, x-parse-app-display-version=1.1.12, x-parse-application-id=29Ce3p2h29Aw9mlUvO8XkMZeXCLKl0SsJbhX8fhN, x-parse-client-key=yRdKparxomNECtqsXFkdHt9U0mKD7du48r9k1Emm, x-parse-client-version=i1.12.0, x-parse-installation-id=b584de1d-b9a1-470e-9292-8ac0a56644be, x-parse-os-version=9.3.3 (13G34), x-parse-session-token=r:9bfe6cf09e278c53537c7736928ddd35, x-forwarded-port=443, x-forwarded-proto=https, eventId=olbsj0M2CG, userId=XwDt4J1yXH, languageCode=fr, cloudCodeAPIVersion=309
�[36mverbose�[39m: REQUEST for [GET] /parse/classes/Event: {
"where": {
"objectId": "olbsj0M2CG"
},
"include": "venue,hostUser,match,tagLine_label,comunities,participants,teams,match.description_label,match.tagLine_label,match.competition.name_label,match.competition.shortName_label,match.competition.mainPicture_image,match.TVChannel1.name_label,match.TVChannel2.name_label,match.TVChannel1.shortName_label,match.TVChannel2.shortName_label,match.TVChannel1.mainPicture_image,match.TVChannel2.mainPicture_image,match.team1.name_label,match.team2.name_label,match.team1.shortName_label,match.team2.shortName_label,match.team1.mainPicture_image,match.team2.mainPicture_image,match.team1.mainCopyrightPicture_image,match.team2.mainCopyrightPicture_image,venue.venueType,venue.name_label,venue.tagLine_label,venue.mainPicture_image,venue.openingHours_label,teams.name_label",
"limit": 1
} method=GET, url=/parse/classes/Event, host=test.superfc.io, x-real-ip=172.31.27.158, x-forwarded-for=52.51.152.96, 172.31.27.158, content-length=1085, accept=/, content-type=text/plain, user-agent=node-XMLHttpRequest, Parse/js1.9.1 (NodeJS 4.4.6), x-forwarded-port=443, x-forwarded-proto=https, objectId=olbsj0M2CG, include=venue,hostUser,match,tagLine_label,comunities,participants,teams,match.description_label,match.tagLine_label,match.competition.name_label,match.competition.shortName_label,match.competition.mainPicture_image,match.TVChannel1.name_label,match.TVChannel2.name_label,match.TVChannel1.shortName_label,match.TVChannel2.shortName_label,match.TVChannel1.mainPicture_image,match.TVChannel2.mainPicture_image,match.team1.name_label,match.team2.name_label,match.team1.shortName_label,match.team2.shortName_label,match.team1.mainPicture_image,match.team2.mainPicture_image,match.team1.mainCopyrightPicture_image,match.team2.mainCopyrightPicture_image,venue.venueType,venue.name_label,venue.tagLine_label,venue.mainPicture_image,venue.openingHours_label,teams.name_label, limit=1

@flovilmart
Copy link
Contributor

In your test function, there's no response, does it crash calling getSessionToken()? Is your big function called directly or part of a hook?

@flovilmart
Copy link
Contributor

Also, this seems to be a very different issue now, as completely unrelated to the original issue.

We have a unit test that specifically cover that: https://github.com/ParsePlatform/parse-server/blob/master/spec/ParseUser.spec.js#L1040

I'm locking that conversation, please reopen an issue.

@parse-community parse-community locked and limited conversation to collaborators Sep 5, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type:bug Impaired feature or lacking behavior that is likely assumed
Projects
None yet
Development

No branches or pull requests

7 participants