一个看似奇怪的 OAuthException
我正在学习构建 Facebook 应用程序,在第一次尝试时,我得到了这个奇怪的 OAuthException。该教程清楚地提到我需要传递redirect_uri、client_secret、client_id 和代码(来自应用程序身份验证阶段)。但是当流程完成时,我得到的不是访问令牌,而是 JSON 错误对象:
{"error":{"message":"client_secret should not be passed to \/oauth\/access_token\/","type":"OAuthException"}}
编辑:这是我用来构建 url 的片段(请原谅过多的第二行),
url = "https://graph.facebook.com/oauth/access_token/"
url += "?"
url += urllib.urlencode([('client_id',client_id),
('redirect_uri', redirect_uri),
('client_secret', client_secret),
('code', code)])
其中变量保存正确的值.(检查> 5次)
I am learning to build fb apps, and on the very first attempt, I get this strange OAuthException. The tutorial clearly mentions that I need to pass redirect_uri, client_secret, client_id and code(from the app auth phase). But when the flow completes, instead of getting an access token here is the JSON error object I get:
{"error":{"message":"client_secret should not be passed to \/oauth\/access_token\/","type":"OAuthException"}}
EDIT: this is the snippet I'm using to build the url(pardon the excessive 2nd line, please)
url = "https://graph.facebook.com/oauth/access_token/"
url += "?"
url += urllib.urlencode([('client_id',client_id),
('redirect_uri', redirect_uri),
('client_secret', client_secret),
('code', code)])
where the variables hold correct values.(checked > 5 times)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该立即删除网址中 access_token 之后的 /,以便它读取
graph.facebook.com/oauth/access_token?
后跟您的参数。如果这不起作用,请显示您生成的完整示例网址(当然,真正的 client_secret x'ed),因为我对 urllib.urlencode 不太熟悉,无法确定格式,尽管该部分看起来一目了然。You should remove the / immediately after access_token in the url so that it reads
graph.facebook.com/oauth/access_token?
followed by your parameters. If that doesn't do it, please show an entire sample url you have generated (with the real client_secret x'ed out of course) since I am not familiar enough with urllib.urlencode to be sure of the formatting, although that part looks right at a glance.