Why is the openID user information not received through the protocol?

I am using DotNetOpenAuth to integrate openID into our web application. The code below requests information from the supplier.

try { var req = openid.CreateRequest(Request.Form["openid_identifier"]); req.AddExtension(new DotNetOpenAuth.OpenId.Extensions.SimpleRegistration.ClaimsRequest { Email = DotNetOpenAuth.OpenId.Extensions.SimpleRegistration.DemandLevel.Require, FullName = DotNetOpenAuth.OpenId.Extensions.SimpleRegistration.DemandLevel.Require, Nickname = DotNetOpenAuth.OpenId.Extensions.SimpleRegistration.DemandLevel.Request, PostalCode = DotNetOpenAuth.OpenId.Extensions.SimpleRegistration.DemandLevel.Request }); return req.RedirectingResponse.AsActionResult(); } 

For some reason, the response from the openID provider never comes with the information I request. Below is the code:

 // Stage 3: OpenID Provider sending assertion response switch (response.Status) { case AuthenticationStatus.Authenticated: Session["FriendlyIdentifier"] = response.FriendlyIdentifierForDisplay; FormsAuthentication.SetAuthCookie(response.ClaimedIdentifier, false); if (!string.IsNullOrEmpty(returnUrl)) { return Redirect(returnUrl); } else { return RedirectToAction("Index", "Home"); } 

I tried: response.ClaimedIdentifier in millions of ways, and it never has any valuable information with which I can do something. Any ideas?

+6
asp.net-mvc openid dotnetopenauth
source share
1 answer

The IAuthenticationResponse.ClaimedIdentifier property never contains these attributes that you request. It contains only the "username" of the OpenID user.

You send the request perfectly. Just add a little to handling the positive answer:

 // Stage 3: OpenID Provider sending assertion response switch (response.Status) { case AuthenticationStatus.Authenticated: Session["FriendlyIdentifier"] = response.FriendlyIdentifierForDisplay; FormsAuthentication.SetAuthCookie(response.ClaimedIdentifier, false); var sreg = response.GetExtension<ClaimsResponse>(); if (sreg != null) { // the Provider MAY not provide anything // and even if it does, any of these attributes MAY be missing var email = sreg.Email; var fullName = sreg.FullName; // get the rest of the attributes, and store them off somewhere. } if (!string.IsNullOrEmpty(returnUrl)) { return Redirect(returnUrl); } else { return RedirectToAction("Index", "Home"); } break; // ... 
+6
source share

All Articles