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

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

Open Jhonemarkus opened this issue 10 years ago • 27 comments

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.

Jhonemarkus avatar May 31 '16 17:05 Jhonemarkus

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 avatar Jun 05 '16 03:06 dcdspace

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

dcdspace avatar Jun 06 '16 03:06 dcdspace

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

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

Jhonemarkus avatar Jun 06 '16 18:06 Jhonemarkus

can you try with access_token instead of accessToken

flovilmart avatar Jun 06 '16 22:06 flovilmart

No news in 20 days, closing.

flovilmart avatar Jun 27 '16 03:06 flovilmart

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

abhijeet-aressindia avatar Nov 08 '16 16:11 abhijeet-aressindia

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

junal avatar Feb 21 '17 20:02 junal

Was anyone able to resolve this issue?

dondragon2 avatar May 09 '17 18:05 dondragon2

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

flovilmart avatar May 09 '17 18:05 flovilmart

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

dondragon2 avatar May 09 '17 18:05 dondragon2

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

junal avatar May 09 '17 18:05 junal

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

dondragon2 avatar May 09 '17 18:05 dondragon2

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

rowntreerob avatar Mar 17 '18 00:03 rowntreerob

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

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

Should be

"authData": {
    "google": {

flovilmart avatar Mar 17 '18 00:03 flovilmart

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.

rowntreerob avatar Mar 17 '18 23:03 rowntreerob

As mentioned above, accessToken should be in snake_case access_token

flovilmart avatar Mar 18 '18 00:03 flovilmart

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 avatar Mar 18 '18 00:03 rowntreerob

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 avatar Mar 18 '18 00:03 rowntreerob

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

image

rowntreerob avatar Mar 18 '18 01:03 rowntreerob

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

flovilmart avatar Mar 18 '18 01:03 flovilmart