gpt4 book ai didi

c# - DotNetOpenAuth 和谷歌

转载 作者:太空宇宙 更新时间:2023-11-03 16:52:42 25 4
gpt4 key购买 nike

我有以下代码:

protected void Page_Load(object sender, EventArgs e)
{
var openId = new OpenIdRelyingParty();
HttpContext httpContext = HttpContext.Current;

var headers = new WebHeaderCollection();
foreach (string header in httpContext.Request.Headers)
{
headers.Add(header, httpContext.Request.Headers[header]);
}

string requestUrl = string.Format("http://localhost:12345/Login/{0}",
httpContext.Request.Url.Query);

var requestInfo = new HttpRequestInfo(httpContext.Request.HttpMethod,
new Uri(requestUrl),
httpContext.Request.RawUrl, headers,
httpContext.Request.InputStream);

var response = openId.GetResponse(requestInfo);

if (response != null)
{
ClaimsResponse claimResponse = response.GetExtension<ClaimsResponse>();
lblUser.Text = claimResponse.FullName;
if (response.Exception != null)
{
lblError.Text = response.Exception.Message;
}
}
}

protected void btnTest_Click(object sender, EventArgs e)
{
try
{
using (OpenIdRelyingParty openId = new OpenIdRelyingParty())
{
string identifier = @"https://www.google.com/accounts/o8/id";


var request = openId.CreateRequest(identifier,
new Realm("http://localhost:12345/"),
new Uri("http://localhost:12345/Login/"));

request.AddExtension(new ClaimsRequest
{
Email = DemandLevel.Require
});

request.RedirectToProvider();
}
}
catch (Exception ex)
{
// TODO: log exception
throw;
}
}

当我执行代码时,用户已通过身份验证,但 ClaimsResponse 为空。
代码适用于 MyOpenId .

如有任何帮助,我们将不胜感激。

最佳答案

这里的信息很有用:Retrieve OpenId User Information (Claims) across providers

您的应用程序中可能缺少的金 block 是 AXFetchAsSregTransform .

关于c# - DotNetOpenAuth 和谷歌,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3387958/

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