我创建了两个名为 s1
和 s2
的 servlet。
s1
将请求转发至
https://graph.facebook.com/oauth/authorize?client_id=41050677*****&redirect_uri=http://localhost:8080/fb10/s2& scope=publish_stream,create_event
在 s2
中,我获取代码并将其重定向到 facebook 成功页面:
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();
进行重定向。
最佳答案
您不不应该进行重定向来用代码交换 token - 考虑一下,请 - 您将应用程序 key 放入此 URL,因此当您将客户端重定向到时,用户可以轻松地在那里找到它!
https://developers.facebook.com/docs/authentication/server-side/ 明确表示步骤4。将代码交换为用户访问 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.
关于java - OAuthException : Error validating verification code,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12417594/