adonisjs / ally

AdonisJS Social Authentication Provider
MIT License
159 stars 53 forks source link

Facebook provider error: ERR_NON_2XX_3XX_RESPONSE #139

Closed herquiloidehele closed 2 years ago

herquiloidehele commented 2 years ago

I am having an generic error on the callback handler when i try to get the user with:

const facebook = ally.use('facebook');

await facebook.user()

The error

{
"name": "HTTPError",
"code": "ERR_NON_2XX_3XX_RESPONSE",
"timings": {
"start": 1646051083250,
"socket": 1646051083252,
"lookup": 1646051083339,
"connect": 1646051083375,
"secureConnect": 1646051083436,
"upload": 1646051083438,
"response": 1646051083757,
"end": 1646051083763,
"phases": {
"wait": 2,
"dns": 87,
"tcp": 36,
"tls": 61,
"request": 2,
"firstByte": 319,
"download": 6,
"total": 513
}
}
}

Package version

"@adonisjs/ally": "^4.1.1",

Node.js and npm version

Node: v14.17.5

NPM: 6.14.14

Sample Code (to reproduce the issue)

 public async facebookOauthCallback({ response, ally }: HttpContextContract) {
    try {
      const facebook = ally.use(allyConfig.facebook.driver);
      const facebookUser = await facebook.user();
      response.send(facebookUser);
    } catch (error) {
      response.badRequest(error);
    }
  }
thetutlage commented 2 years ago

Can you log error.response.body to see the actual error the request has received from Facebook

herquiloidehele commented 2 years ago

Yes, the error presented:

{"error":{"message":"API calls from the server require an appsecret_proof argument","type":"GraphMethodException","code":100,"fbtrace_id":"AAVzcDTvtvYAXE4uaaB-mAK"}}
herquiloidehele commented 2 years ago

I had to disable that feature from facebook developer portal, and it fixed now. Thanks.

thetutlage commented 2 years ago

Great. You have it working :). Closing the issue