我有一个制作应用程序,偶尔我会看到这个错误出现在日志中..我似乎无法在我的结尾复制它,所以似乎有一个用户在某处具有某些特定设置/导致此问题的cookie / etc。我不知道......该日志表明,该用户被重定向到这个回调URL: “用户/认证/ Facebook的/回调代码= AQCayaAoFOruFgwbfg1D682j8DbxOt0CZYNH3Vv5RtYKlQgSzISyN8ygTn25W_RTl3fu35cS1-tl5ArZ9B_XylwORP0hGU6st8P6TyTYUzfiR1m0poaSRkX-KBeWiBvT6IUsm-Af0VJcUNTQPg-dM1F9y5CgJ2bTJEJqhCE9wYlvkUY3kguwcl3TQ48FTT4-PHA ///”
实际错误是:
RuntimeError: #<OAuth2::Response:0x1da7fae0 @error=#<OAuth2::Error: OAuth2::Error>, @options={:parse=>:query}, @parsed={"{\"error\":{\"message\":\"Invalid verification code format.\",\"type\":\"OAuthException\"}}"=>nil}, @response=#<Faraday::Response:0x1da8fa80 @on_complete_callbacks=[], @env={:response=>#<Faraday::Response:0x1da8fa80 ...>, :request_headers=>{"Content-Type"=>"application/x-www-form-urlencoded"}, :body=>"{\"error\":{\"message\":\"Invalid verification code format.\",\"type\":\"OAuthException\"}}", :status=>400, :url=>#<Addressable::URI:0xed52bf0 URI:https://graph.facebook.com/oauth/access_token>, :request=>{:proxy=>nil}, :parallel_manager=>nil, :response_headers=>{"expires"=>"Sat, 01 Jan 2000 00:00:00 GMT", "access-control-allow-origin"=>"*", "content-type"=>"text/javascript; charset=UTF-8", "connection"=>"close", "www-authenticate"=>"OAuth \"Facebook Platform\" \"invalid_code\" \"Invalid verification code format.\"", "date"=>"Thu, 13 Oct 2011 15:58:29 GMT", "content-length"=>"81", "cache-control"=>"no-store", "x-fb-rev"=>"457598", "x-fb-server"=>"10.65.13.60", "pragma"=>"no-cache"}, :ssl=>{:ca_file=>"/etc/pki/tls/certs/ca-bundle.crt"}, :method=>:post}>>
参数是:
{"code"=> "AQCayaAoFOruFgwbfg1D682j8DbxOt0CZYNH3Vv5RtYKlQgSzISyN8ygTn25W_RTl3fu35cS1-tl5ArZ9B_XylwORP0hGU6st8P6TyTYUzfiR1m0poaSRkX-KBeWiBvT6IUsm-Af0VJcUNTQPg-dM1F9y5CgJ2bTJEJqhCE9wYlvkUY3kguwcl3TQ48FTT4-PhA///",
"action"=>"",
"controller"=>""}
我知道如果我手动转到“users / auth / facebook / callback?code = blah”它会触发同样的错误,因为回调代码参数显然是假的,但看起来并不像是有什么可疑的用户的参数哈希中的实际代码 - 所以我想知道为什么它会是一个无效的格式?
还有其他人经历过这个吗?
答案 0 :(得分:-1)
我认为以下链接提供了答案:http://developers.facebook.com/docs/authentication/#authenticating-users-in-a-web-application
首先需要使用client_id和redirect_uri调用https://graph.facebook.com/oauth/authorize。然后,这将重定向回redirect_uri,查询字符串中的验证码可以传递给https://graph.facebook.com/oauth/access_token调用(通过代码参数)以交换oAuth访问令牌。
祝你好运! :)