简体   繁体   中英

Find a user from an access_token

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

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.

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

您可以使用此位置的Facebook开发人员可用的调试器https://developers.facebook.com/tools/debug您可以了解有关所有访问令牌的更多信息 - 用户,应用和页面。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM