Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 793
heiningair Avatar asked Sep 04 '14 09:09

heiningair


People also ask

What is access token in Facebook API?

An access token is an opaque string that identifies a user, app, or Page and can be used by the app to make graph API calls. When someone connects with an app using Facebook Login and approves the request for permissions, the app obtains an access token that provides temporary, secure access to Facebook APIs.

Is Facebook Graph API deprecated?

Applies to all versions. Facebook Analytics will no longer be available after June 30, 2021. Additionally, we are deprecating the App Dashboard Plugin for Marketing API. For more information visit the Business Help Center.

What is an Oauth exception on Facebook?

OAuthException: If you receive an OAuthException error, it means that Edgar doesn't have the correct permissions to access your Facebook accounts right now. The password may have been changed on Facebook or Facebook may have reset your security session.


2 Answers

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.

like image 92
Niraj Shah Avatar answered Sep 22 '22 21:09

Niraj Shah


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.

like image 42
Moonchild Avatar answered Sep 25 '22 21:09

Moonchild