无法从 Facebook 获取访问令牌.收到 OAuthException 提示“验证验证码时出错"; [英] Unable to get access token from Facebook. Got an OAuthException says "Error validating verification code"

查看:32
本文介绍了无法从 Facebook 获取访问令牌.收到 OAuthException 提示“验证验证码时出错";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 Java,我的演示应用程序的目的很简单:更新用户状态.我遵循了http://developers.facebook.com/docs/authentication<页面上的服务器端流程/a>.我得到了 auth 对话框,facebook 指向回调 url,我在我的回调页面中得到了 code.然后当我尝试生成访问令牌时失败了.

I am using java and the purpose of my demo application is simple: Update user status. I followed the Server-side Flow on page http://developers.facebook.com/docs/authentication. I got the auth dialog, facebook lead to the callback url and I got the code in my callback page. Then I failed when I try to generate an access token.

在指南页面中,它说以下网址可用于生成访问令牌:

In the guide page, it says the following url could be used to generated an access token:

https://graph.facebook.com/oauth/access_token?
     client_id=YOUR_APP_ID&redirect_uri=YOUR_URL&
     client_secret=YOUR_APP_SECRET&code=THE_CODE_FROM_ABOVE

但是在我的环境中发生的情况是我收到以下错误消息:

But what happens in my environment is I got the following error message:

{
   "error": {
      "type": "OAuthException",
      "message": "Error validating verification code."
   }
}

我很确定每个参数都是正确的,因为如果我更改 client_id 值或 client_secret 参数,我将收到不同的错误消息.代码参数是我从 facebook 回调中得到的.所以这应该是正确的,对吧?实在想不通是什么问题....

I am quite sure every parameter is correct because if I change the client_id value or client_secret parameter, I will got a different error message. The code parameter is what I got from facebook callback. So this should be correct, right? Really can't figure out what is the problem....

对此有什么想法吗?我卡在这里了...

Any idea about this? I get stuck here...

推荐答案

我最近正好处理了这个问题:一切都匹配,但失败了 OAuthException.使它工作的事情是从以下位置更改重定向 uri(在两个流请求中):

I recently dealt with exactly this problem: everything matched, but it failed with the OAuthException. The thing that made it work was to change the redirect uri (in both requests for the flow) from:

http://foo.example.com

http://foo.example.com/

即,添加尾部斜杠.然后它起作用了.愚蠢和愚蠢,但你去了.

I.e., add the trailing slash. And then it worked. Stupid and silly, but there you go.

这篇关于无法从 Facebook 获取访问令牌.收到 OAuthException 提示“验证验证码时出错";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆