Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the Facebook user id using the access token

I have a Facebook desktop application and am using the Graph API. I am able to get the access token, but after that is done - I don't know how to get the user's ID.

My flow is like this:

  1. I send the user to https://graph.facebook.com/oauth/authorize with all required extended permissions.

  2. In my redirect page I get the code from Facebook.

  3. Then I perform a HTTP request to graph.facebook.com/oauth/access_token with my API key and I get the access token in the response.

From that point on I can't get the user ID.

How can this problem be solved?

like image 789
Mohoch Avatar asked Aug 23 '10 10:08

Mohoch


People also ask

What is the use of Facebook access token?

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.

How do I use access tokens?

Access tokens are used in token-based authentication to allow an application to access an API. The application receives an access token after a user successfully authenticates and authorizes access, then passes the access token as a credential when it calls the target API.


1 Answers

If you want to use Graph API to get current user ID then just send a request to:

https://graph.facebook.com/me?access_token=... 
like image 103
serg Avatar answered Sep 30 '22 18:09

serg