gpt4 book ai didi

.net - OpenAuth .Net 声明请求始终为空

转载 作者:行者123 更新时间:2023-12-01 10:13:42 26 4
gpt4 key购买 nike

我一直在使用 DoNetOpenAuth 库并遵循示例 here

身份验证有效,但即使我需要电子邮件,claimsresponse 仍为空。事实上,不管我要求什么,claimsresponse 总是空的。不确定我做错了什么,非常感谢您的帮助。

提前致谢。

这是我的登录按钮代码

protected void btnSubmit_Click( object sender, EventArgs e )
{
//Login button has been pushed. Add an extension and redirect
using (OpenIdRelyingParty openId = new OpenIdRelyingParty())
{
IAuthenticationRequest request = openId.CreateRequest( txtOpenID.Text );

request.AddExtension( new ClaimsRequest
{
Email = DemandLevel.Require,
Country = DemandLevel.Request,
TimeZone = DemandLevel.Request
} );

request.RedirectToProvider();

}
}

这是页面加载代码。 ClaimsResponse 变量始终为 null。

protected void Page_Load( object sender, EventArgs e )
{
OpenIdRelyingParty openId = new OpenIdRelyingParty();
var response = openId.GetResponse();

//check if we're processing a request
if(response != null)
{
switch ( response.Status )
{
case AuthenticationStatus.Authenticated:

//authentication worked. grab our required fields
var claimsResponse = response.GetExtension<ClaimsResponse>();

//TODO enter required fields into the database

break;
case AuthenticationStatus.Canceled:
//TODO handle cancel
break;

case AuthenticationStatus.Failed:
//TODO handle failed
break;
}
}
}

最佳答案

最后:问题出在 web.config 中

添加

<configuration>    <configSections>        <section name="dotNetOpenAuth" type="DotNetOpenAuth.Configuration.DotNetOpenAuthSection" requirePermission="false" allowLocation="true"/></configSections></configuration><dotNetOpenAuth><openid><relyingParty><behaviors><add type="DotNetOpenAuth.OpenId.Behaviors.AXFetchAsSregTransform, DotNetOpenAuth"/>                </behaviors></relyingParty></openid></dotNetOpenAuth>

就是这样,它应该可以工作。

关于.net - OpenAuth .Net 声明请求始终为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3129013/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com