-1

I'm really puzzled about this, I know there is a couple of duplicate posts like this around, done quite some reading and I know a bit about ClaimsResponse (at least i think i do) working with both SREG and AX information, web.config configuration for enabling AXFetchAsSregTransform, how to use ClaimsRequest to get Google Email with DemandLevel.Require. What i'm trying to do is getting my sample to work (sample used from strathweb) with unified DotNetOpenAuth.dll library after v4.0 as a single reference to my project not a nuget package. Sample works with version DotNetOpenAuth-3.4.7.11121. I would greatly appreciate if anyone could give me some info regarding this problem. All goes well when I am creating request and using DotNetOpenAuth.dll v3.4.7:

public IAuthenticationRequest ValidateAtOpenIdProvider(string openIdIdentifier, Realm realm, Uri returnurl)

{

IAuthenticationRequest openIdRequest = openId.CreateRequest(Identifier.Parse(openIdIdentifier), realm, returnurl);

        var fields = new ClaimsRequest()
        {
            Email = DemandLevel.Require,
            FullName = DemandLevel.Require,
            Nickname = DemandLevel.Require
        };
        openIdRequest.AddExtension(fields);

        return openIdRequest;
    }

And redirecting the user to the service provider:

var response = openidemembership.ValidateAtOpenIdProvider(identifier, realm, new Uri("DomainUrl or Localhost/GoogleCallback"));

        if (response != null)
        {
            return response.RedirectingResponse.AsActionResult();
        }

After User is redirected back those 2 methods are called:

public OpenIdUser GetUser() {

        OpenIdUser user = null;
        IAuthenticationResponse openIdResponse = openId.GetResponse();

        if (openIdResponse.IsSuccessful())
        {
            user = ResponseIntoUser(openIdResponse);
        }

        return user;
    }

private OpenIdUser ParseResponse(IAuthenticationResponse response) {

        OpenIdUser user = null;
        var claimResponseUntrusted = response.GetUntrustedExtension<ClaimsResponse>();
        var claimResponse = response.GetExtension<ClaimsResponse>();
                  if (claimResponse != null)
        {
            user = new OpenIdUser(claimResponse, response.ClaimedIdentifier);
        }
        else if (claimResponseUntrusted != null)
        {
            user = new OpenIdUser(claimResponseUntrusted, response.ClaimedIdentifier);
        }

        return user;
    }

Inside the controller :

public ActionResult GoogleCallback() {

        var user = openidemembership.GetUser();
        if (user != null)
        {
            //Create cookie and redirect the user back 
            return new RedirectResult(Request.Params["ReturnUrl"] ?? "/");
        }

        return View();
    }

Web.Config

 <section name="dotNetOpenAuth" type="DotNetOpenAuth.Configuration.DotNetOpenAuthSection" requirePermission="false" allowLocation="true" />

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

still after using DotNetOpenAuth.dll v4.0 +++, inside ParseResponse method call i can't get any values from ClaimsResponse. And i am using namespace DotNetOpenAuth.OpenId.Extensions.SimpleRegistration. With nuget everything is fine, but is there any other way to get it working with single dll, i really don't wont to add all those references from nuget to my existing project which i am currently working on for one of my customers, thank you in advance.

Undectu
  • 3
  • 2

1 Answers1

0

Update your web.config file to use DotNetOpenAuth.OpenId.RelyingParty.Behaviors.AXFetchAsSregTransform. (Note the change in namespace to add "RelyingParty" to it. In v4.x, DotNetOpenAuth moved the namespace of behaviors in order to support the multi-assembly builds, and it impacted even the unified assembly versions.

<dotNetOpenAuth>
    <openid>
      <relyingParty>
        <behaviors>
          <add type="DotNetOpenAuth.OpenId.RelyingParty.Behaviors.AXFetchAsSregTransform, DotNetOpenAuth" />
        </behaviors>
      </relyingParty>
    </openid>
  </dotNetOpenAuth>

Also, you can still use NuGet to get DotNetOpenAuth even if you want the unified assembly:

Install-Package DotNetOpenAuth.Ultimate

Andrew Arnott
  • 80,040
  • 26
  • 132
  • 171
  • Andrew - Thank you very much for your quick answer. NuGet package DotNetOpenAuth.Ultimate did work, anyway I've tried including the namespace in the web.config file as suggested but the problem still persists. I would rather avoid using nuget except if there is no cleaner solution to this. Much appreciated, best regards. – Undectu Jan 15 '13 at 07:52
  • Well to debug any further, please rerun the scenario [with logs](http://tinyurl.com/dnoalogs) and attach the logs to your question. – Andrew Arnott Jan 15 '13 at 14:15
  • Sorry for not replying sooner. It seems I did not set up my web config file correctly. With above setup and changing the namespace as suggested, code did work with v4+ but only for FetchResponse and not for ClaimsResponse. After I changed my web.config file to sectionGroup (as in NuGet package DotNetOpenAuth.Ultimate) which holds openid, oauth, messaging and reporting sections ClaimsResponse started to work. Thank you for your time and concern Andrew, you helped me a lot. Keep up the good work! – Undectu Jan 16 '13 at 22:22