facebook 错误“验证验证码时出错" [英] facebook error 'Error validating verification code'

查看:270
本文介绍了facebook 错误“验证验证码时出错"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

非常奇怪的错误.我使用 gide http://developers.facebook.com/docs/authentication/.所以我创建了对 fb 的请求并传递了 redirect_uri.我在本地主机上使用测试站点.所以如果我通过

very strange error. i use gide http://developers.facebook.com/docs/authentication/. so i create request to fb and pass redirect_uri. i use test site on localhost. so if i pass

redirect_uri=http://localhost/test_blog/index.php

redirect_uri=http://localhost/test_blog/index.php

它工作正常,但如果我通过

it works fine, but if i pass

redirect_uri=http://localhost/test_blog/index.php?r=site/oauth2

redirect_uri=http://localhost/test_blog/index.php?r=site/oauth2

它不想工作.我尝试使用

it don't want work. i try to use

redirect_uri= .urlencode('http://localhost/test_blog/index.php?r=site/oauth2)

redirect_uri= . urlencode('http://localhost/test_blog/index.php?r=site/oauth2)

但不起作用.我试着解释一下.我成功获得代码,但是当我访问 https://graph.facebook.com/me?access_token 我收到错误验证验证码时出错".我检查过,错误在 ?r=site/oauth2 但我需要传递一些参数有人可以帮我吗?我读了帖子 http://forum.developers.facebook.net/viewtopic.php?id=70855 但对我没有任何作用

but not work. i try to explaine. i success get code, but when i access https://graph.facebook.com/me?access_token i get error 'Error validating verification code'. i checked evering, error is in ?r=site/oauth2 but i need passing some params can somebody help me? i read post http://forum.developers.facebook.net/viewtopic.php?id=70855 but nothing work for me

推荐答案

目前(截至 2011 年 3 月)有关于什么是有效的 redirect_uri 的未记录要求.

There are presently (as of March 2011) undocumented requirements regarding what makes a valid redirect_uri.

首先,要授权的redirect_uri参数和access_token必须匹配.

显然 Facebook(或者说 OAuth2)正在使用 redirect_uri 作为内部密钥来编码为 access_token 请求返回的代码.这有点聪明,因为它会验证回您的网站.它解释了为什么不需要 redirect_uri 参数的 access_token 请求需要一个.

Apparently Facebook (or rather OAuth2) is using the redirect_uri as a internal key to encode the code returned for the access_token request. It's kinda clever since it verifies back to your site. It explains why the access_token request which wouldn't otherwise need a redirect_uri parameter requires one.

第二,你不能在redirect_uri中使用很多特殊字符.

关于参数是否可以传递的问题引起了很多讨论.他们可以,您可以限制哪些字符有效,但没有人发布过我知道的列表.像 url/html 编码这样的传统方法会失败,因为百分比 (%) 无效.斜线 (/) 也无效,因此嵌套重定向 url 将始终失败.克服特殊字符限制的唯一方法是将参数值编码为 base64.如果您使用的是 ASP.NET,请查找 Convert.ToBase64.

A lot of discussion rages whether parameters can be passed at all. They can, you're limited which characters are valid but no one has published a list that I know. Traditional methods like url/html encoding will fail because percent(%) is not valid. Slash (/) is not valid either so a nested redirection url will always fail. The ONLY way to overcome the special char limitation is to encode the value of the parameter to base64. If you're using ASP.NET, look up Convert.ToBase64.

最后,这更像是一个旁注.有很多程序员传递错误信息,一个简单的解决方案是传递 type=client_cred.这可能会限制您访问您在授权中请求的某些权限.这是不可取的.

Lastly, and this is more of a side-note. There are a lot of programmers passing along misinformation that a simple solution is to pass type=client_cred. This may limit your access to some of the permissions you requested in your authorization. It is inadvisable.

这篇关于facebook 错误“验证验证码时出错"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆