views:

376

answers:

1

hi i am trying to setup DotNetOpenAuth using the OpenIdAjaxTextBox but i have two problems

  1. i want to be able to get the users email address and i think that is done in the loggedin event (right?) but that event is never called, i have tried to setup a breakpoint there but i never get to it.

  2. when I type in the openid provider in the OpenIdAjaxTextBox (lets say Gmail), I get the login button in the textbox so I click on it a new windows pops up and displayes the Gmail login form but after that i type my username and password and click on login that popup window refresh and my own website loads in that popup window, i would expect the pop up window to close after I login not redirect me to my site.

here is the code I using

<%@ Register Assembly="DotNetOpenAuth" Namespace="DotNetOpenAuth.OpenId.RelyingParty"
    TagPrefix="openid" %>

    <openid:OpenIdAjaxTextBox ID="OpenIdAjaxTextBox1" runat="server" 
        OnLoggingIn="openIdtxtbx_LoggingIn" 
        OnLoggedIn="openIdtxtbx_LoggedIn" 
        OnClientAssertionReceived="onauthenticated(sender)"
        OnUnconfirmedPositiveAssertion="openIdtxtbx_UnconfirmedPositiveAssertion" />

    Protected Sub openIdtxtbx_LoggedIn(ByVal sender As Object, ByVal e As OpenIdEventArgs)
        ' Do something here
        Dim claimedId As String = e.Response.Status
    End Sub

    Protected Sub openIdtxtbx_LoggingIn(ByVal sender As Object, ByVal e As OpenIdEventArgs)
        ' Retrieve the email address of the user
        Dim c As New ClaimsRequest
        c.Email = DemandLevel.Require
        e.Request.AddExtension(c)
    End Sub

    Protected Sub openIdtxtbx_UnconfirmedPositiveAssertion(ByVal sender As Object, ByVal e As OpenIdEventArgs)
        ' This is where we register extensions that we want to have available in javascript
        ' on the browser.
        OpenIdAjaxTextBox1.RegisterClientScriptExtension(Of ClaimsResponse)("sreg")
    End Sub
A: 

The OpenIdAjaxTextBox.LoggedIn event isn't fired until a postback from the web page -- a submit button of some sort. The Login button on the text box itself is not a postback, so you need to add some other submit button to your page.

e.Response.Status is not a claimed identifier. You should change your LoggedIn event handler to read:

Dim claimedId As String = e.ClaimedIdentifier

You won't get an email address from Google using ClaimsRequest unless you are using the AXFetchAsSregTransform behavior.

updated: Finally regarding the popup window not disappearing at the end of login... it should work the way you think it should. But there's a "bug" that the OpenIdAjaxTextBox doesn't support POST responses, which is what you get when you ask for attributes due to the size of the response payload. v3.3 fixes this, but it isn't released yet. Sorry about that.

Andrew Arnott
1. I did a postback and the LoggedIn event fires as expected.
Murre
2. about the popup window, I ran the sample and I have been able to reproduce the problem there. I modefied the ajaxlogin.aspx.cs line 14 from Email = DemandLevel.Request,to Email = DemandLevel.Require,so I just changed the demandlevel to Require and that causes the popup window not to close.So I did some further debugging and found out that the error is due to an "instance of an object not found" which originates from the "ReportAuthenticationResult() line 1413" in the source cod (v.3.2.2.9257). (I have tried google and yahoo as an openid provider.)any idea what I am doing wrong?
Murre
btw, u r doing an awesome job with openid Andrew :) ones my web app is up and running u can expect a donation
Murre
Thanks so much for giving me the repro (and for the donation offer). I'll work on it once my day job is over tonight.
Andrew Arnott
Ok, so here's what's happening (on my box anyway)... in v3.2, OpenIdAjaxTextBox does not support POST OpenID requests or responses. This was an intentional scope limitation back when the control was originally written. When you require the email attribute, Google supplies it and it just pushes the response over the limit of GET's payload size so POST is used, and the ajax box malfunctions. The good news is, this is already fixed in what's slated for a v3.3 release (POST is supported, yay!) A workaround for v3.2 in my next comment...
Andrew Arnott
...ok, we're back....and the workaround I was going to propose doesn't work. The response is too big to fit in a GET and v3.2 doesn't let you do what you need to do to get the response any smaller. So I'm afraid if you need attributes (and gosh, I don't know why I didn't catch this sooner for v3.2!) the ajax text box in v3.2 won't work for you. You'll have to wait for v3.3. You _could_ be a beta tester for v3.3 now if you want: http://teamcity.dotnetopenauth.net/ and download the "master - nightly build" build's artifact: DotNetOpenAuth-3.3.0.*.zip.
Andrew Arnott
thank you very much, I will download the nightly build and test it and report any bugs. when do you expect (or guess) v3.3 to be released?
Murre
It's 3-4 weeks away from how it's looking today.
Andrew Arnott