我在我的网站上使用DNOA进行身份验证+授权。
http://ugi-2.apphb.com/Authentication.htm
当我在本地主机上运行时,我收到此错误
return_to 'http://localhost:8976/Register/Login' not under realm 'http://anonymous/'.
来自这段代码:
private void HandleAuthNullResponse(IAuthenticationResponse authResponse)
{
// Google requires that the realm and consumer key be equal,
// so we constrain the realm to match the realm in the web.config file.
// This does mean that the return_to URL must also fall under the key,
// which means this sample will only work on a public web site
// that is properly registered with Google.
// We will customize the realm to use http or https based on what the
// return_to URL will be (which will be this page).
var consumer = new WebConsumer(GoogleConsumerHelper.ServiceDescription, mConsumerTokenManager);
//Realm realm = "http://localhost:8976/";
Realm realm = System.Web.HttpContext.Current.Request.Url.Scheme + Uri.SchemeDelimiter + consumer.ConsumerKey + "/";
IAuthenticationRequest authReq = GoogleConsumerHelper.RelyingParty.CreateRequest(GoogleConsumerHelper.GoogleOPIdentifier, realm);
错误符合DNOA评论的内容
很奇怪,因为我看到其他代码适用于localhost,但结构较差。
然后我转向谷歌网站并看到:
注册您的网络应用程序
注册有三个级别:
未注册:Google无法识别申请。访问 请求页面,提示您的用户授予或拒绝访问权限 对于您的应用程序,以黄色突出显示此警告: “此网站尚未在Google注册。我们建议你 只有在您信任此目的地时才能继续此过程。“
已注册:......
- 醇>
注册了增强的安全性:...
注册是可选的,但建议使用。 ...
我甚至试图在appHarbor上发布,但没有帮助(还没有日志)
我该如何解决这个问题?
答案 0 :(得分:0)
您看到的错误消息是因为OpenID规范要求return_to URL是领域URL的衍生物,显然在您的情况下不是。 http://localhost/不会落在http://anonymous/下的任何地方。如果您将领域设置为站点的实际根URL,以便return_to位于其下,则此错误应该消失。
我有兴趣看到谷歌的文档说它接受http://anonymous/领域和return_to除匿名以外的任何东西。