OAuthException:验证码验证错误 [英] OAuthException: Error validating verification code
问题描述
我创建了两个名为s1
和s2
的servlet.
I have created two servlets named s1
and s2
.
s1
将请求转发给
https://graph.facebook.com/oauth/authorize?client_id=41050677*****&redirect_uri=http://localhost:8080/fb10/s2& scope=publish_stream,create_event
在s2
中,我正在获取代码并将其重定向到Facebook成功页面:
In s2
I am getting the code and redirecting it to facebook success page:
https://graph.facebook.com/oauth/access_token?client_id=410506779*********&redirect_uri=http://www.facebook.com/connect/login_success.html& client_secret=22049dc145289c2dd7**************&code=(extract code form url)
但是我遇到一个错误:
{
"error": {
"message": "Error validating verification code.",
"type": "OAuthException",
"code": 100
}
}
这是怎么引起的,我该如何解决?我已经使用responce.sendredirect();
进行重定向.
How is this caused and how can I solve it? I have used responce.sendredirect();
for redirection.
推荐答案
您不应该进行重定向以将代码交换为令牌– 再想一想,请 –您将应用程序的机密信息放到该URL中,因此当您将客户端重定向到该URL时,用户可能会发现它在那里很容易!
You are not supposed to make a redirect to exchange the code for a token – think about it for a second, please – you are putting your app secret into this URL, so when you redirect the client to it, the user could spot it there easily!
https://developers.facebook.com/docs/authentication/server-side /对步骤 4明确地说出 .将代码交换为用户访问令牌:
https://developers.facebook.com/docs/authentication/server-side/ says explicitly for step 4. Exchange the code for a User Access Token:
一旦用户授权了您的应用,您应该发出服务器边请求,以将上面返回的代码交换为用户访问令牌.
Once the user has authorized your app, you should make a server side request to exchange the code returned above for a user access token.
这篇关于OAuthException:验证码验证错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!