Unable to get attributes from DotNetOpenId response

I am trying to figure out how to get user information after checking through the public identifier. It doesn't matter if I put RequestsRequest or FetchRequest when I call

response.GetExtension<ClaimsResponse> //Or response.GetExtension<FetchResponse> //Or response.GetUntrustedExtension<ClaimsResponse> // OR response.GetUntrustedExtension<FetchResponse> 

I always get a null link. I am adding information in the same way as in all the examples that I saw like this:

 request.AddExtension(new ClaimsRequest{ Email = DemandLevel.Require }); // Or var fetch = new FetchRequest(); fetch.Attributes.AddRequired(WellKnownAttributes.Contact.Email); request.AddExtension(fetch); 

Any idea what I'm doing wrong?

Update

Adding configuration information proposed by Andrew, I was interested. I finally return ClaimsResponse using response.GetUntrustedExtension<ClaimsResponse> , however response.GetExtension<ClaimsResponse> still returns null. Also, the returned ClaimsResponse request does not actually contain any data that I requested. Here's the request:

 var request = openId.CreateRequest(Request.Form["openid_identifier"]); request.AddExtension(new ClaimsRequest { BirthDate = DemandLevel.Request, Country = DemandLevel.Request, Email = DemandLevel.Require, FullName = DemandLevel.Request, Gender = DemandLevel.Request, Language = DemandLevel.Request, Nickname = DemandLevel.Request, PostalCode = DemandLevel.Request, TimeZone = DemandLevel.Request }); return request.RedirectingResponse.AsActionResult(); 

Here is my configuration

  <uri> <idn enabled="All"/> <iriParsing enabled="true"/> </uri> <dotNetOpenAuth> <openid maxAuthenticationTime="0:05"> <relyingParty> <security requireSsl="false" minimumRequiredOpenIdVersion="V10" minimumHashBitLength="160" maximumHashBitLength="256" requireDirectedIdentity="false" requireAssociation="false" rejectUnsolicitedAssertions="false" rejectDelegatingIdentifiers="false" ignoreUnsignedExtensions="false" privateSecretMaximumAge="07:00:00" /> <behaviors> <add type="DotNetOpenAuth.OpenId.Behaviors.AXFetchAsSregTransform, DotNetOpenAuth" /> </behaviors> </relyingParty> </openid> <messaging> <untrustedWebRequest> <whitelistHosts> <!-- since this is a sample, and will often be used with localhost --> <add name="localhost" /> </whitelistHosts> </untrustedWebRequest> </messaging> 

I am running v3.2.0.9177

+7
openid dotnetopenauth
source share
1 answer

It is possible that the provider you are testing with does not support these extensions. Or, if itโ€™s Google, it only answers the question once (if during the login you donโ€™t leave โ€œRemember meโ€).

Now with DotNetOpenAuth v3.2, the best way to submit extensions is probably to use the new behavior attribute extension. It will automatically use sreg and / or AX (in three different AX formats), depending on the Provider, to maximize your chances of getting a useful result if the provider supports any of these extensions at all.

Paste this bit into your web.config file, where the full configuration wiki page is offered.

 <behaviors> <add type="DotNetOpenAuth.OpenId.Behaviors.AXFetchAsSregTransform, DotNetOpenAuth" /> </behaviors> 

Then use ClaimsRequest / ClaimsResponse (sreg) instead of AX ' FetchRequest so that the behavior can do its job.

Since you mentioned that you are testing myopenid.com, I also throw away heads-ups that seem to have disabled extension support when you test an RP that is located at "localhost". Obviously, your RP must be publicly available and possibly even open (according to OpenID 2.0 rules for detecting RP) to execute an attribute request. It may be what you use.

+10
source share

All Articles