heiningair
heiningair

Reputation: 451

Facebook graph api returns 400 bad request with correct access token

I just manually implemented a facebook oauth2 flow into my webapp. After receiving the correct access_token and trying to call the graph api for user data I got a 400 BAD REQUEST as response.

GET https://graph.facebook.com/me?accessToken=MY_CORRECT_TOKEN&fields=id,name,email

When I use exactly the same call within the dev tools provided on facebook it succeeds, but when I try using any other http client it doesnt work. I already tried it with curl, apache commons and some other http clients.

Is there someone able to help me with this?

Thanks in advance

Upvotes: 14

Views: 37630

Answers (4)

user25099495
user25099495

Reputation: 1

In my case I used an outdated api version (v17.0 instead of v20.0)

[edit] See the deadlines of various apis here: https://developers.facebook.com/docs/marketing-api/marketing-api-changelog/versions

Upvotes: 0

markhorrocks
markhorrocks

Reputation: 1398

In my case, my "permanent" access token expired.

Upvotes: 2

Moonchild
Moonchild

Reputation: 1562

For people landing here with the same error message but different problem, you can also check, if you have both IPv4 and IPv6 connections, that both IPs (v4 and v6) are authorized in Facebook OAuth parameters (on developer.facebook.com). That solved my problem.

Upvotes: 2

Niraj Shah
Niraj Shah

Reputation: 15457

The format of your API call is incorrect. Try the following instead:

GET https://graph.facebook.com/me?access_token=MY_CORRECT_TOKEN&fields=id,name,email

The accessToken in your URL should actually be access_token.

Upvotes: 6

Related Questions