Find a user from an access_token

310 Views Asked by At

Is it possible to find out in which user an access_token belongs to?

I have an access_token. And I would like to find the user id that created this access_token.

Thanks

3

There are 3 best solutions below

0
Maggie On BEST ANSWER

Yes, user id is contained in the access token. If you have an access token that looks something like:

1234567890|2.a3KGHbLrzTqw__.86400.129394400-102450226|-XY1zH_PN-nbTtyhDPc

102450226 is your used id. You would have to do split the string by "|", take the middle part then split by "-" and take the last part.

2
Igy On

Maggie's answer is correct, although the fact that the uid is visible in the string of the access token may not always be true. That said, I'm not aware of anything on the roadmap to change the access token format.

Two other options:

  1. Make a graph API call to https://graph.facebook.com/me?fields=id&access_token=[ACCESS TOKEN HERE] - if the token is still valid you'll get back an answer like this:

    {        
    "id": "[UID HERE]"
    }
    
  2. Use the access token linter at https://developers.facebook.com/tools/access_token/lint

0
Usha On

You can use the debugger available for facebook developers at this location https://developers.facebook.com/tools/debug You can know more about all the access tokens - user, app and page.