从 cookie 获取访问令牌以与 Facebook Graph API 一起使用
假设我有一个用户登录到 Facebook(Cookie 保存在浏览器的缓存中),获取其访问令牌的最简单方法是什么? 我正在尝试 Facebook 的 Graph API,我不想为了获取访问令牌而创建应用程序(至少现在不想)。
如果我没记错的话,几天前我去了 http://graph.facebook.com/me在我的浏览器上(登录时),它将我重定向到 http://graph.facebook.com/ me?access_token=...,但现在我明白了(并且没有重定向):
{
"error": {
"type": "OAuthException",
"message": "An active access token must be used to query information about the current user."
}
}
不幸的是,我不能依赖以前回答的问题,因为我坚信事情最近发生了变化。
Assuming I have a user logged in to Facebook (Cookies are saved in the browser's cache), what is the simplest way to get its access token?
I'm experimenting with Facebook's Graph API, and I don't want to bother with creating an application in order to get access tokens (at least not now).
If I remember correctly, a few days ago I went to http://graph.facebook.com/me on my browser (while being logged in), which redirected me to http://graph.facebook.com/me?access_token=..., but now I get that instead (and no redirection):
{
"error": {
"type": "OAuthException",
"message": "An active access token must be used to query information about the current user."
}
}
Unfortunately, I couldn't rely on previously answered questions, since I strongly believe things changed very recently.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要的所有文档都在这里:
https://developers.facebook.com/docs/authentication/
如果您只想要一个为自己测试 API 中的某些内容的访问令牌,您可以使用 Graph API Explorer ( https://developers .facebook.com/tools/explorer )为您生成该应用程序的访问令牌并将其复制/粘贴到您的代码中。
请务必包含“offline_access”权限以获得不会很快过期的令牌。
All the docs you're going to need are here:
https://developers.facebook.com/docs/authentication/
If you just want a single access token for yourself to test some things in the API, you could use the Graph API Explorer ( https://developers.facebook.com/tools/explorer ) to generate an access token for you for that app and copy/paste it to your code.
Be sure to include the 'offline_access' permission to get a token which won't quickly expire.
你根本做不到!
您需要创建一个应用程序才能生成
access_token
(成功验证/授权后)。有关此内容的更多信息,请参见此处。Simply you can't!
You need to create an application to be able to generate an
access_token
(after a successful authentication/authorization). More about this here.