【发布时间】:2013-08-19 21:49:06
【问题描述】:
我正在编写如下的自定义 Open Id 客户端
public class CustomOpenIdClient : OpenIdClient
{
public CustomOpenIdClient() : base("TestOpenId", "`http://localhost:39167/server.aspx`")
{
}
protected override Dictionary<string, string> GetExtraData(IAuthenticationResponse response)
{
FetchResponse fetchResponse = response.GetExtension<FetchResponse>();
if (fetchResponse != null)
{
var extraData = new Dictionary<string, string>();
extraData.Add("email", fetchResponse.GetAttributeValue(WellKnownAttributes.Contact.Email));
extraData.Add("fullname", fetchResponse.GetAttributeValue(WellKnownAttributes.Name.FullName));
return extraData;
}
return null;
}
protected override void OnBeforeSendingAuthenticationRequest(IAuthenticationRequest request)
{
var fetchRequest = new FetchRequest();
fetchRequest.Attributes.AddRequired(WellKnownAttributes.Contact.Email);
fetchRequest.Attributes.AddRequired(WellKnownAttributes.Name.FullName);
request.AddExtension(fetchRequest);
}
}`
如代码所示,我尝试使用的 OpenIdProvider 是 http://localhost:39167/,它由 DotNetOAuth 示例开发,即 OpenIdWebRingSsoProvider 和 OpenIdWebRingSsoRelyingParty,在 RP webconfig 中定义为
`<appSettings>
<add key="SsoProviderOPIdentifier" value="http://localhost:39167/"/>
<add key="SsoProviderOPEndpoint" value="http://localhost:39167/server.aspx"/>
</appSettings>`
我正在我的网站中将 CustomOpenIdClient 注册为
OAuthWebSecurity.RegisterClient(new CustomOpenIdClient(), "TestOpenId", new Dictionary<string, object>());
现在,当我尝试进行身份验证时,我得到 No OpenId End Point found
OAuthWebSecurity.RequestAuthentication(Provider, ReturnUrl)
本地主机已经在 RP 的 webconfig 中的白名单中定义。 请让我知道我在这里遗漏了什么导致此 No OpenId End point 错误?
谢谢,
某人
【问题讨论】:
-
当返回通用错误消息时,可能会出现很多问题。我建议配置日志记录,这将产生有关幕后发生的事情的更详细信息。请参阅 DNOA 文档中的这篇文章:github.com/DotNetOpenAuth/DotNetOpenAuth/wiki/…
标签: c# openid dotnetopenauth openid-provider