如果我有用户的 oauth_token,如何获取他/她的 access_token?
当用户打开我的画布应用程序时,我会从 Facebook 收到一个 signed_request
,从中派生出 user_id
和 oauth_token
。我怎样才能获取access_token
并检查/获取用户权限和其他数据?
When user opens my canvas app I get a signed_request
from Facebook, from which I derive the user_id
and oauth_token
. How can I then get the access_token
and check/get user permissions and other data?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你所说的oauth_token也是用户的access_token,它们应该是完全相同的。
要检查用户权限,您可以对 /me/permissions 进行 GET 调用,这应该返回类似于以下内容的数据数组,
具体取决于您希望访问的其他数据,您需要请求更多权限,然后调用相应的 API终点。例如,要获取用户的基本信息,请致电
/me
或获取他们的朋友列表/me/friends
您可以找到您可以请求的所有权限在 https://developers.facebook.com/docs/reference/api/permissions/< /a>
以及有关在 API 中调用何处的所有信息在这里检索您需要的不同数据位 https://developers.facebook.com/docs/reference /api/
The oauth_token you're talking about is also the users access_token, they should be exactly the same.
To check the users permissions you can make a GET call to /me/permissions this should return a data array similar to the below
Depending on what the other data you wish to access you will need to ask for more permissions and then call the appropriate API end points. For example to get the users basic information make a call to
/me
or to get a list of their friends/me/friends
You can find all the permissions you can ask for at https://developers.facebook.com/docs/reference/api/permissions/
And all the information about where to call in the API for retrieving the different bits of data you require here https://developers.facebook.com/docs/reference/api/
当您说您拥有他们的“oauth 令牌”时,您确定这不是访问令牌吗?您可以尝试使用该令牌对
/me/permissions
进行 API 调用,看看它是否有效吗?它应该返回用户授予您的应用程序的权限列表(可通过该令牌使用)When you say you have their 'oauth token' - are you sure that isn't the access token? Can you try making an API call to
/me/permissions
with that token and see if it's working? It should return a list of the permissions the user has granted your app (which are usable via that token)