无法从Facebook获取访问令牌。 OAuthException表示“验证验证码错误” [英] Unable to get access token from Facebook. Got an OAuthException says "Error validating verification code"

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

问题描述

我正在使用java,我的演示应用程序的目的很简单:更新用户状态。
我按照 http://developers.facebook.com/上的服务器端流文档/认证。我得到了auth对话框,Facebook导致回调URL,我在回调页面中得到了代码。然后当我尝试生成访问令牌时,我失败了。



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

  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

但是,在我的环境中会发生什么以下错误消息:

  {
error:{
type:OAuthException
message:验证验证码错误。
}
}

我确信每个参数都是正确的,因为如果我更改client_id值或client_secret参数,我将收到一个不同的错误消息。代码参数是我从Facebook回调获得的。所以这应该是对的,对吧?真的不明白是什么问题....



有什么想法吗?我被困在这里...

解决方案

我最近处理了这个问题:一切都匹配,但是与OAuthException失败。使它工作的事情是改变重定向uri(在两个请求的流程)从:



http://foo.example.com





http://foo.example.com/



即可添加尾部斜线。然后它工作。愚蠢和愚蠢,但你去。


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."
   }
}

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...

解决方案

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

to

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天全站免登陆