简体   繁体   English

从access_token中查找用户

[英]Find a user from an access_token

Is it possible to find out in which user an access_token belongs to? 是否有可能找出access_token属于哪个用户?

I have an access_token. 我有一个access_token。 And I would like to find the user id that created this access_token. 我想找到创建此access_token的用户ID。

Thanks 谢谢

Yes, user id is contained in the access token. 是的,用户ID包含在访问令牌中。 If you have an access token that looks something like: 如果您有一个类似于以下内容的访问令牌:

1234567890|2.a3KGHbLrzTqw__.86400.129394400-102450226|-XY1zH_PN-nbTtyhDPc 1234567890 | 2.a3KGHbLrzTqw __ 86400.129394400-102450226 |。-XY1zH_PN,nbTtyhDPc

102450226 is your used id. 102450226是您的二手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. Maggie的回答是正确的,尽管uid在访问令牌的字符串中可见这一事实可能并非总是如此。 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: https://graph.facebook.com/me?fields=id&access_token=[ACCESS TOKEN HERE]进行图形API调用 - 如果令牌仍然有效,您将得到如下答案:

     { "id": "[UID HERE]" } 
  2. Use the access token linter at https://developers.facebook.com/tools/access_token/lint https://developers.facebook.com/tools/access_token/lint上使用访问令牌linter

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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