使用 DotNetOpenAuth 从 OpenID 提供商获取电子邮件地址
我无法获取 GetExtension
方法中返回的电子邮件地址,但它包含在 Google(我正在测试的 OP)发回给我的 URL 中。
if (Page.IsPostBack)
{
using (var openid = new OpenIdRelyingParty())
{
var request = openid.CreateRequest(Request.Form["openid_identifier"]);
var fetch = new FetchRequest();
fetch.Attributes.Add(new AttributeRequest(WellKnownAttributes.Contact.Email, true));
request.AddExtension(fetch);
request.RedirectToProvider();
}
}
else
{
using (var openid = new OpenIdRelyingParty())
{
var response = openid.GetResponse();
if (response != null)
{
switch (response.Status)
{
case AuthenticationStatus.Authenticated:
var claimsResponse = response.GetExtension<FetchRequest>();
break;
case AuthenticationStatus.Canceled:
//this.loginCanceledLabel.Visible = true;
break;
case AuthenticationStatus.SetupRequired:
//this.loginFailedLabel.Visible = true;
break;
// We don't need to handle SetupRequired because we're not setting
// IAuthenticationRequest.Mode to immediate mode.
////case AuthenticationStatus.SetupRequired:
//// break;
}
}
}
}
任何人都知道出了什么问题吗?
I can't get the email address returned in GetExtension
method, but it is included in the url that Google (the OP I'm testing with) sends back to me.
if (Page.IsPostBack)
{
using (var openid = new OpenIdRelyingParty())
{
var request = openid.CreateRequest(Request.Form["openid_identifier"]);
var fetch = new FetchRequest();
fetch.Attributes.Add(new AttributeRequest(WellKnownAttributes.Contact.Email, true));
request.AddExtension(fetch);
request.RedirectToProvider();
}
}
else
{
using (var openid = new OpenIdRelyingParty())
{
var response = openid.GetResponse();
if (response != null)
{
switch (response.Status)
{
case AuthenticationStatus.Authenticated:
var claimsResponse = response.GetExtension<FetchRequest>();
break;
case AuthenticationStatus.Canceled:
//this.loginCanceledLabel.Visible = true;
break;
case AuthenticationStatus.SetupRequired:
//this.loginFailedLabel.Visible = true;
break;
// We don't need to handle SetupRequired because we're not setting
// IAuthenticationRequest.Mode to immediate mode.
////case AuthenticationStatus.SetupRequired:
//// break;
}
}
}
}
Anyone knows what's wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试以下代码:
Try the following code:
在 C# 中,以上内容都不适合我(使用 PayPal Access 作为标识符)
以下内容对我有用:
None of the above worked for me (using PayPal Access as a identifier) in C#
The below worked for me: