简体   繁体   English

OAuth“无效的验证码格式”

[英]OAuth “Invalid verification code format”

I've got a production app and occasionally I see this error appear in the logs.. I can't seem to duplicate it on my end, so it seems like there is a user out there somewhere with some specific settings / cookies / etc that are causing this problem. 我有一个生产应用程序,有时我看到这个错误出现在日志中..我似乎无法复制它在我的结尾,所以似乎有一个用户在那里的某些特定设置/ cookies /等导致这个问题。 I am not sure... The log shows that this user was redirected to this callback url: "users/auth/facebook/callback?code=AQCayaAoFOruFgwbfg1D682j8DbxOt0CZYNH3Vv5RtYKlQgSzISyN8ygTn25W_RTl3fu35cS1-tl5ArZ9B_XylwORP0hGU6st8P6TyTYUzfiR1m0poaSRkX-KBeWiBvT6IUsm-Af0VJcUNTQPg-dM1F9y5CgJ2bTJEJqhCE9wYlvkUY3kguwcl3TQ48FTT4-PhA///" 我不知道......该日志表明,该用户被重定向到这个回调URL:“用户/认证/ Facebook的/回调代码= AQCayaAoFOruFgwbfg1D682j8DbxOt0CZYNH3Vv5RtYKlQgSzISyN8ygTn25W_RTl3fu35cS1-tl5ArZ9B_XylwORP0hGU6st8P6TyTYUzfiR1m0poaSRkX-KBeWiBvT6IUsm-Af0VJcUNTQPg-dM1F9y5CgJ2bTJEJqhCE9wYlvkUY3kguwcl3TQ48FTT4-PHA ///?”

The actual error is: 实际错误是:

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

and the parameters were: 参数是:

{"code"=> "AQCayaAoFOruFgwbfg1D682j8DbxOt0CZYNH3Vv5RtYKlQgSzISyN8ygTn25W_RTl3fu35cS1-tl5ArZ9B_XylwORP0hGU6st8P6TyTYUzfiR1m0poaSRkX-KBeWiBvT6IUsm-Af0VJcUNTQPg-dM1F9y5CgJ2bTJEJqhCE9wYlvkUY3kguwcl3TQ48FTT4-PhA///",
"action"=>"",
"controller"=>""}

I know if I manually go to "users/auth/facebook/callback?code=blah" it will trigger this same error because the callback code parameter is obviously bogus, but it doesn't look like there's anything suspicious about the actual code in the user's params hash-- so I am wondering why it would be an invalid format? 我知道如果我手动转到“users / auth / facebook / callback?code = blah”它会触发同样的错误,因为回调代码参数显然是假的,但看起来并没有任何关于实际代码的可疑信息。用户的参数哈希 - 所以我想知道为什么它会是一个无效的格式?

Has anyone else experienced this? 还有其他人经历过这个吗?

I think the following link provides the answer: http://developers.facebook.com/docs/authentication/#authenticating-users-in-a-web-application 我认为以下链接提供了答案: http//developers.facebook.com/docs/authentication/#authenticating-users-in-a-web-application

You first need to call https://graph.facebook.com/oauth/authorize with your client_id and redirect_uri. 首先需要使用client_id和redirect_uri调用https://graph.facebook.com/oauth/authorize This will then redirect you back to the redirect_uri, with a verification code in the query string that you can pass to your https://graph.facebook.com/oauth/access_token call (via the code parameter) to exchange for an oAuth access token. 然后,这将重定向回redirect_uri,查询字符串中的验证码可以传递给您的https://graph.facebook.com/oauth/access_token调用(通过代码参数)以交换oAuth访问权限令牌。

Good luck! 祝好运! :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM