views:

161

answers:

1

I'm trying to get DotNetOpenAuth (latest version) to work with ASP.NET MVC 2 website. I get the first part working, the action is invoked when user selects OpenID provider, I get correct identifier passed in, I then get correctly redirected to the provider website, I get redirected back to my website but here's the problem.

The claims I requested are null (see the code below).

public ActionResult TryAuth(string openid_identifier)
{
    var openid = new OpenIdRelyingParty();
    var response = openid.GetResponse();
    if(response== null)
    {
        var req = openid.CreateRequest(openid_identifier);
        req.AddExtension(new ClaimsRequest
                            {
                                Email = DemandLevel.Require,
                                Nickname = DemandLevel.Require
                            });
        return req.RedirectingResponse.AsActionResult();
    }
    switch(response.Status)
    {
        case AuthenticationStatus.Authenticated:
            {
                var data = response.GetExtension(typeof(ClaimsResponse)) as ClaimsResponse;
                // data is null <-----------------------------------------
                return View("Index");
            }
    }
    return View("Index");
}

I would greatly appreciate if anyone can point out the (not so) obvious mistake I'm making.

+2  A: 

Please look through all the similar questions at http://stackoverflow.com/search?q=claimsresponse+null

Your code looks fine. Make sure you activate the AXFetchAsSregTransform in your web.config file though to maximize the chance of you getting something back. It's up to the Provider to give you any attributes though. Some Providers like Yahoo require that your RP correctly implement RP Discovery, which the sample RPs that come with DotNetOpenAuth demonstrate.

Here is my blog post on getting RP Discovery done right. Do this, and try the sites you've been testing against again. Keep in mind as well that some Providers cache RP Discovery results, so you might apply all your RP Discovery fixes, and still have to wait an hour or a day before the Providers start giving you data.

Andrew Arnott
Bah, StackOverflow search sucks (or I do) - suggestions it showed up contained none of the questions you linked. Thanks - I'll have a look
Krzysztof Koźmic
I tried three providers - myopenid, google and technorati and none of them returned anything
Krzysztof Koźmic
(I'm not too fond of StackOverflow's search feature myself. It needs a +keyword feature to force matches)
Andrew Arnott
Do you have the AXFetchAsSregTransform wired up?
Andrew Arnott
Just beefed up my answer to include a blog post on RP Discovery.
Andrew Arnott
ok, doing the config trick seems to have helped
Krzysztof Koźmic