How can I get AttributeExchange and / or SimpleRegistration working with MVC?

I am banging my head against a wall trying to get AttributeExchange or SimpleRegistration while working with 3.2.0.9257 version of DotNetOpenAuth .

Here's what I did:

  • Downloaded tag 3.2.0.9257 from GitHub
  • Opened DotNetOpenAuth visual studio solution.
  • Made a change to the OpenIdRelyingPartyMvc sample

All changes are in the UserController's Authenticate method.

I replaced line 44,

return openid.CreateRequest(Request.Form["openid_identifier"]).RedirectingResponse.AsActionResult();

      

with the following:

var request = openid.CreateRequest(Request.Form["openid_identifier"]);

// Add SimpleRegistration requests for Email and FullName
var sr = new ClaimsRequest();
sr.Email = DemandLevel.Request;
sr.FullName = DemandLevel.Request;
request.AddExtension(sr);

// Add AttributeExchange requests for Email and FullName
var ax = new FetchRequest();
ax.Attributes.Add(new AttributeRequest(WellKnownAttributes.Contact.Email));
ax.Attributes.Add(new AttributeRequest(WellKnownAttributes.Name.FullName));
request.AddExtension(ax);

return request.RedirectingResponse.AsActionResult();

      

(I also added the DotNetOpenAuth.OpenId.Extensions.AttributeExchange and DotNetOpenAuth.OpenId.Extensions.SimpleRegistration namespaces.)

Then, further in the same method, after "Stage 3 Authenticated", I try to get the answers:

var sr = response.GetExtension<ClaimsResponse>();
var ax = response.GetExtension<FetchResponse>();

      

However, these answers are always zero. I've tried Google, Yahoo and MyOpenID. In all cases, authentication works correctly, but SimpleRegistration or AttributeExchange data is not returned.

What am I doing wrong?

+2


source to share


1 answer


Google does not support sreg, and its AX support is only for email and only if you marked the email address as "required" (your code uses "optional" by default).

Yahoo does not support AX, and its sreg support is for whitelisting only.



MyOpenID supports sreg, and uses AX differently than DotNetOpenAuth. Are you sure ClaimsResponse is NULL when used against MyOpenID? Because in my tests it works fine.

You might end up having to send sreg and AX requests and 3 different flavors of AX simply by using the AXFetchAsSregTransform behavior described in Retrieving User Attributes of the DotNetOpenAuth documentation.

+5


source







All Articles