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

logInWith() google oauth gives error 252 this authentication method is unsupported #1961

Closed
Jhonemarkus opened this issue May 31, 2016 · 27 comments

Comments

@Jhonemarkus
Copy link

Jhonemarkus commented May 31, 2016

I'm trying to login with Google oauth. The Google login goes OK but when I try to login to Parse it gives me the error.

My Parse-server init:

new ParseServer({
databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
appId: process.env.APP_ID || '@@@@',
masterKey: process.env.MASTER_KEY || '@@@@',
serverURL: process.env.SERVER_URL || 'http://192.168.0.20:1337/parse',
});

And on the client app (JS):

var _this = this;
return new Promise((resolve,reject)=>{
window.plugins.googleplus.login({'webClientId':'@@@','offline':'true'},
function(user_data){
//returns {email:'',userId:'',displayName:'',oauthToken:'',...}
var provider = {
authenticate(options) {
if (options.success) {
options.success(this, {});
}
},
restoreAuthentication(authData) {},
getAuthType() {
return 'google';
},
deauthenticate() {}
};
var user = new _this.Parse.User();
var authData = {accessToken:user_data.oauthToken,id:user_data.userId};
_this.Parse.User.logInWith(provider,authData)
.then((user)=>{
console.debug(user);
resolve(user);
})
.catch((error)=>{
console.error(error);
reject(error);
});
},
function(msg){
reject(msg);
});
});

Logs/Trace

The server log:

verbose: POST /parse/users { host: '192.168.0.35:1337',
connection: 'keep-alive',
'content-length': '142',
'x-devtools-emulate-network-conditions-client-id': '5C0C4D6A-3CDD-4D93-8F94-5B011B91D4E4',
origin: 'file://',
'user-agent': 'Mozilla/5.0 (Linux; Android 5.1.1; SM-J200BT Build/LMY47X; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/50.0.2661.86 Mobile Safari/537.36',
'content-type': 'text/plain',
accept: '/',
'accept-encoding': 'gzip, deflate',
'accept-language': 'pt-BR,en-US;q=0.8',
'x-requested-with': 'br.com.clarity.uptaxi.clientdev' } {
"authData": {
"google": {}
}
}
verbose: error: code=252, message=This authentication method is unsupported.

@dcdspace
Copy link

dcdspace commented Jun 5, 2016

I too am receiving this error when trying to implement Google Oauth. I have the token from Google, but I get the exact same thing.

@dcdspace
Copy link

dcdspace commented Jun 6, 2016

You have to pass in the id parameter as well as access_token in authData.

@Jhonemarkus
Copy link
Author

I'm already passing the id.
this is my authData:

{
"accessToken":<google_oauthToken>,
"id":<google_userId>
}

@flovilmart
Copy link
Contributor

can you try with access_token instead of accessToken

@flovilmart
Copy link
Contributor

No news in 20 days, closing.

@abhijeet-aressindia
Copy link

@flovilmart i am trying to use google oath for login/signup and getting the following error.
we've hosted our Parse Server to Heroku and current version is 2.2.21.

this is also added in configuration.
oauth: {
google: true,
---------
---------
}

2016-11-08T14:34:28.586045+00:00 heroku[router]: at=info method=POST path="/server/users" host=espressoft-parse-server.herokuapp.com request_id=c398099d-5188-435f-8b82-0f89c8b1301b fwd="49.248.139.244" dyno=web.1 connect=0ms service=58ms status=404 bytes=549
2016-11-08T14:34:28.528042+00:00 app[web.1]: verbose: REQUEST for [POST] /server/users: {
2016-11-08T14:34:28.528058+00:00 app[web.1]: "authData": {
2016-11-08T14:34:28.528059+00:00 app[web.1]: "google": {
2016-11-08T14:34:28.528061+00:00 app[web.1]: "access_token": "################",
2016-11-08T14:34:28.528062+00:00 app[web.1]: "id": "################"
2016-11-08T14:34:28.528063+00:00 app[web.1]: }
2016-11-08T14:34:28.528064+00:00 app[web.1]: }
2016-11-08T14:34:28.528066+00:00 app[web.1]: } method=POST, url=/server/users, host=espressoft-parse-server.herokuapp.com, connection=close, x-parse-revocable-session=1, x-parse-os-version=6.0.1, x-parse-app-build-version=9, x-parse-client-key=, x-parse-client-version=a1.13.0, x-parse-app-display-version=1.2.0, x-parse-installation-id=664921b2-09ab-4510-8a84-4f19865cae02, user-agent=Parse Android SDK 1.13.0 (com.hp.babyapp/9) API Level 23, x-parse-application-id=j836GbrAG1uquh1GtkhliEau1B0ylheZXW8Zqk4Y, content-type=application/json, accept-encoding=gzip, x-request-id=c398099d-5188-435f-8b82-0f89c8b1301b, x-forwarded-for=49.248.139.244, x-forwarded-proto=https, x-forwarded-port=443, via=1.1 vegur, connect-time=0, x-request-start=1478615668526, total-route-time=0, content-length=144, access_token=ya29.CjCQA8qOWPU--i6GwW2XM3xRbB4fDKfK5FcV9mERhdzx73j5Ye8aB34H3S3Au3S-iXo, id=114480623117503118429
2016-11-08T14:34:28.582638+00:00 app[web.1]: error: Error generating response. ParseError { code: 101, message: 'Google auth is invalid for this user.' } code=101, message=Google auth is invalid for this user.
2016-11-08T14:34:28.583839+00:00 app[web.1]: [object Object]

Do you have any suggestions on this?

@junal
Copy link

junal commented Feb 21, 2017

@Jhonemarkus What solution you found for "This authentication method is unsupported."?

@dondragon2
Copy link

Was anyone able to resolve this issue?

@flovilmart
Copy link
Contributor

Try using id_token instead of access token in your login payload.

@dondragon2
Copy link

dondragon2 commented May 9, 2017

I tried the following but still getting the issue
const { type, idToken, user } = resp; if (type === 'success') { const { id, name, email, photoUrl } = user; const authData = { id, id_token: idToken, };

and on the server side I am seeing:
0|parse-se | error: Error generating response. ParseError { 0|parse-se | code: 252, 0|parse-se | message: 'This authentication method is unsupported.' } code=252, message=This authentication method is unsupported. 0|parse-se | [object Object] 0|parse-se | verbose: REQUEST for [POST] /parse/users: { 0|parse-se | "authData": { 0|parse-se | "google": {} 0|parse-se | } 0|parse-se | }

@junal
Copy link

junal commented May 9, 2017

@dondragon2 This is what worked for me...
authData = { authData: { id: id, access_token: accessToken } }; Parse.User.logInWith('facebook' authData);

@dondragon2
Copy link

@junal I am trying to do a google login. the facebook login works fine

@rowntreerob
Copy link

did the google interface ( what API for "authData" when vendor is 'google' ) ever get resolved?

I tried a bunch of permutaions for authData obj content and they all fail on a variety of errors ( stdout belo )


 "authData": {
    "[object Object]": {
      "access_token": "ya29.zsVg"   
    }
 -- also added "id_token":  {{ google uid }} to above getting same error ( 252)
  }
} method=POST, url=/parse/users, host=localhost:1337, connection=keep-alive, content-length=328, pragma=no-cache, cache-control=no-cache, origin=http://
...
error: Error generating response. ParseError {
  code: 252,
  message: 'This authentication method is unsupported.' } code=252, message=This authentication method is unsupported.

....

verbose: REQUEST for [POST] /parse/users: {
  "authData": {
    "[object Object]": {
      "id": "itnxB53",
      "access_token": "S0708299-UQ"
    }
  }
} method=POST, url=/parse/users, host=localhost:1337, connection=keep-alive, content-length=364, pragma=no-cache, cache-control=no-cache, origin=http://
...
error: Error generating response. ParseError {
  code: 105,
  message: 'Invalid key name: authData.[object Object].id' } code=105, message=Invalid key name: authData.[object Object].id

@flovilmart
Copy link
Contributor

@rowntreerob the authData you're sending from the client is invalid. As you can see here:

 "authData": {
    "[object Object]": {

Should be

"authData": {
    "google": {

@rowntreerob
Copy link

rowntreerob commented Mar 17, 2018

fixed the fields (authData) and tried again using curl for the post , it is still failing -
message: 'Google auth is invalid for this user.' } code=101,
Im getting the oAuth portion on the client from lib=firebaseui-web and it seems to be working fine. The error is on the server...

IMO - as the parse user does not yet exist, this POST should create a new row in _User where "userName" = {{ google.id }} and where authData field below gets copied into parseUser column "authData" .. but it errors out instead.

verbose: REQUEST for [POST] /parse/users: {
  "authData": {
    "google": {
      "id": "itnxB53",
      "accessToken": "ya29.Gl13YA"
    }
  }
}
 method=POST, url=/parse/users, host=localhost:1337, user-agent=curl/7.47.0, accept=*/*, x-parse-application-id=Mrc7, content-type=application/json, x-parse-revocable-session=1, x-parse-rest-api-key=eKw7, content-length=209, id=itd8B53, accessToken=ya29.Gly13YA
error: Error generating response. ParseError { code: 101, message: 'Google auth is invalid for this user.' } code=101, message=Google auth is invalid for this user.
error: Google auth is invalid for this user. code=101, message=Google auth is invalid for this user.

@flovilmart
Copy link
Contributor

As mentioned above, accessToken should be in snake_case access_token

@rowntreerob
Copy link

fwiw the values above :
google.id
google.accessToken

were taken from the response "handleSignedInUser" over in the firebaseUI part of the client
the img shows the JSON returned by firebase and the field values i used in the curl.POST

image

@rowntreerob
Copy link

using "id" , "access_token" in the interface does not change the response to the post to "parse/users"...

< HTTP/1.1 100 Continue
* We are completely uploaded and fine
< HTTP/1.1 404 Not Found
< X-Powered-By: Express
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Methods: GET,PUT,POST,DELETE,OPTIONS
< 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
< Content-Type: application/json; charset=utf-8
< Content-Length: 60
< ETag: W/"3c-XEyoHa+xAbiRnB2uzyQCyX4uovo"
< Date: Sun, 18 Mar 2018 00:30:17 GMT
< Connection: keep-alive
< 
* Connection #0 to host localhost left intact
{"code":101,"error":"Google auth is invalid for this user."}rob@ src$ 

@rowntreerob
Copy link

i left out the 2nd property value returned by firebaseUI that was used to set the value of "accessToken" in the interface

image

@flovilmart
Copy link
Contributor

Try using the idToken and send it to parse-server as id_token

@rowntreerob
Copy link

rowntreerob commented Mar 18, 2018

no change on using id_token in interface with the corresponding value supplied by firebaseUI...

on each attempt i make 2 tries using both "uid" and "provider[0].uid" as the "id" value in the parse/user call. I suspect/guess that google wants me to be using "provider[0].uid"

see first of the 2 images above for the JSON details coming from firebaseUI call...


  -d '{"authData":{"google":{"id":"itB53","id_token":"eyJhbGciOiJSUzI1NiIsImtpZCI6ImM2ZjBlZTE2YmU3MGM0ODhkZDM5ZGI3MGY2ZjRkMTM3YTA0ODkxZTMifQ.DU7-kg"}}}'
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 1337 (#0)
> POST /parse/users HTTP/1.1
> Host: localhost:1337
> User-Agent: curl/7.47.0
> Accept: */*
> X-Parse-Application-Id: 0676uMrc7
> Content-Type: application/json
> X-Parse-Revocable-Session: 1
> X-Parse-REST-API-Key: 8zy7eKw7
> Content-Length: 960
> 
* upload completely sent off: 960 out of 960 bytes
< HTTP/1.1 404 Not Found
< X-Powered-By: Express
< Access-Control-Allow-Origin: *
< Access-Control-Allow-Methods: GET,PUT,POST,DELETE,OPTIONS
< 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
< Content-Type: application/json; charset=utf-8
< Content-Length: 60
< ETag: W/"3c-XEyoHa+xAbiRnB2uzyQCyX4uovo"
< Date: Sun, 18 Mar 2018 01:17:09 GMT
< Connection: keep-alive
< 
* Connection #0 to host localhost left intact
{"code":101,"error":"Google auth is invalid for this user."}

@flovilmart
Copy link
Contributor

I’m not sure this is an issue with parse server, as we’re using the google login in a production app and it’s working as expected. Open a question on stackoverflow as it may be more fitting than here.

Thanks.

Note that the google login is expected to work with the google auth SDK’s and android, not fire base.

@rowntreerob
Copy link

OK.. firebaseUI not compatible/interoperable with parse-server... I get it now.

thanks

@flovilmart
Copy link
Contributor

You can always provide you own custom authAdapter on parse-server to support it
The job of an auth adapter is to validate the credentials passed in the authData payload.

Have a look into the auth adapters folder, and there’s only one method to implement to support your fire base UI credentials.

It’s not because out of the box those credentials aren’t supported that you’re completely locked out.

The best part, you can bring your own auth adapter without changing any internal code.

@rowntreerob
Copy link

will give that a try ... thank you

@rowntreerob
Copy link

Did not need a new adapter for firebaseUI - just more accurate mapping.

It finally worked ( i think it was a combined mapping issue firebaseUI.CB vs authData values && provider scopes issue )

stdout below shows mapping of authData field values ( id, access-token):

verbose: REQUEST for [POST] /parse/users: {
  "authData": {
    "google": {
      "id": "103782719223218325285",              // from firebaseUI.user.providerData[0].uid
      "access_token": "ya29.GluDBbHtAh2OJQu8FU"  // from firebaseUI.credential.accessToken
    }
  }
} method=POST, url=/parse/users, host=localhost:1337, user-agent=curl/7.47.0, accept=*/*, x-parse-application-id=067nMrc7, content-type=application/json, x-parse-revocable-session=1, x-parse-rest-api-key=8zTuuKw7, content-length=201, id=103782719223218325285, access_token=ya29.GluDBb8FU
api rsp {
 "azp": "950737254621-m52k6l7ci62bdql0fld9hgtmjvfqq2hu.apps.googleusercontent.com",
 "aud": "950737254621-m52k6l7ci62bdql0fld9hgtmjvfqq2hu.apps.googleusercontent.com",
 "sub": "103782719223218325285",
 "scope": "https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/plus.me https://www.googleapis.com/auth/plus.circles.members.read https://www.googleapis.com/auth/plus.profile.agerange.read https://www.googleapis.com/auth/plus.profile.language.read https://www.googleapis.com/auth/plus.moments.write",
 "exp": "1521491888",
 "expires_in": "2847",
 "email": "rowntrob@gmail.com",
 "email_verified": "true",
 "access_type": "online"
}

verbose: RESPONSE from [POST] /parse/users: {
  "status": 201,
  "response": {
    "objectId": "TaRFKQXRDR",
    "createdAt": "2018-03-19T19:50:41.359Z",
    "username": "wr2trM6auN5w24N0TlWkO7bVk",
    "sessionToken": "r:70c1377bc44cfd41a807e916a26f2850"
  },
  "location": "http://localhost:1337/parse/users/TaRFKQXRDR"
} status=201, objectId=TaRFKQXRDR, createdAt=2018-03-19T19:50:41.359Z, username=wr2trM6auN5w24N0TlWkO7bVk, sessionToken=r:70c1377bc44cfd41a807e916a26f2850, location=http://localhost:1337/parse/users/TaRFKQXRDR

@flovilmart
Copy link
Contributor

Glad to hear it worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants