views:

32

answers:

1

I am trying to implement OpenID for a website using only Google as the authentication provider. I am using the OpenIdButton control to send users to their Google Apps login since I always want them to go to the same place.

The button sends them to the right place and returns them to the ReturnToUrl correctly but it doesn't seem that the OnLoggedIn event ever fires. I am checking the event by setting a TextBox value in the method and I am seeing no change in the TextBox value. Here is my code...

<tr>
  <td>
    <asp:TextBox ID="devMsg" runat="server"/>
  </td>
</tr>
<tr>
  <td valign="top" align="center">
    <font size="-1"><b>Sign in with your</b></font>
    <br />
    <br />
<rp:OpenIdButton ID="OpenIdButton1" runat="server" Text="Login with your Google account!"
             ImageUrl="http://www.google.com/accounts/google_transparent.gif"
                 Identifier="https://www.google.com/accounts/o8/site-xrds?hd=dev.connexcloud.com"
                 ReturnToUrl="http://localhost:1587/OpenIdRelyingPartyWebForms/loginGoogleApps.aspx"
                 OnLoggedIn="OpenIdLogin_LoggedIn" />
    <br />
    <br />
    <font size="-1"><b>Account</b></font>
  </td>
</tr>


protected void OpenIdLogin_LoggedIn(object sender, OpenIdEventArgs e)
{
  this.devMsg.Text = "no response";

  if (e.Response != null)
  {
    devMsg.Text = "response";

    switch (e.Response.Status)
    {
      case AuthenticationStatus.Authenticated:
           this.devMsg.Text = "authenicated";
           break;
      case AuthenticationStatus.Canceled:
           this.devMsg.Text = "canceled";
           break;
      case AuthenticationStatus.Failed:
           this.devMsg.Text = "failed";
           break;
    }
  }
}

The TextBox is never being set to anything so it looks to me like the OpenIdLogin_LoggedIn call is never being made when the response is coming back from Google.

+1  A: 

Have you tried setting a breakpoint in your LoggedIn handler? I suspect it's working. After the LoggedIn handler is invoked, the control calls FormsAuthentication.RedirectFromLoginPage with the OpenID claimed identifier, which would scrub the TextBox that you're setting in it before you noticed it.

Another way besides a breakpoint you can test it is by setting e.Cancel = true in your handler, which suppresses the subsequent call to FormsAuthentication.RedirectFromLoginPage.

Andrew Arnott
Thanks for the input Andrew. I tried setting a breakpoint and I also tried your suggestion of e.Cancel = true. The LoggedIn handler is definitely not being called. I did succeed in processing the response in the Page_Load method but I would like to get it to work the right way. Simply put, it's as though the OpenIdLogin_LoggedIn handler isn't even there. Not being called and no errors are reported during the build.
JediPotPie