authToken error when registering with RPX and Facebook

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
12/5/2009 3:50:52 AM
Gravatar
Total Posts 4

authToken error when registering with RPX and Facebook

Hello,

I recently installed mojoPortal 2.3.3.0 from source code on my development machine (windows server 2008 / IIS 7 / MSSQL) and I seem to be having problems when I try to register a new user using RPX and Facebook. The website redirects me to Facebook, where I am able to log in successfully, and then I am redirected back to my site. At this point mojoPortal asks for my email address (some additional information is required to register) and when I click the create account button, the server throws the following error:

Object reference not set to an instance of an object.
Source Error: Line 54: if (authToken.Length == 0)
Source File: C:\inetpub\wwwroot\mojoportal\Web\Secure\OpenIdRpxHandler.aspx.cs Line: 54

Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
mojoPortal.Web.UI.OpenIdRpxHandlerPage.Page_Load(Object sender, EventArgs e) in C:\inetpub\wwwroot\mojoportal\Web\Secure\OpenIdRpxHandler.aspx.cs:54
System.Web.UI.Control.OnLoad(EventArgs e) +131
mojoPortal.Web.mojoBasePage.OnLoad(EventArgs e) in C:\inetpub\wwwroot\mojoportal\Web\Components\mojoBasePage.cs:555
System.Web.UI.Control.LoadRecursive() +65
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2427

The authToken appears to be null even though you set the value here:
OpenIdRpxHandler.aspx.cs, Line 581: authToken = Request.Params.Get("token");

I am using a fresh install of mojoPortal with no custom code yet implemented. I have only seen this issue when logging in using Facebook, although the only other service I have tested is Google (which works fine). Any help you can provide would be greatly appreciated.

Thanks,
Adam

12/5/2009 6:37:20 AM
Gravatar
Total Posts 18439

Re: authToken error when registering with RPX and Facebook

Hi Adam,

Can you try a small code change and see if it solves the problem?

In the LoadSettings method, please change this:

authToken = Request.Params.Get("token");

to this:

 

if (Request.Params.Get("token") != null)
            {
                authToken = Request.Params.Get("token");
            }

if (Request.Params.Get("token") != null)  {  authToken = Request.Params.Get("token");   }

After making this change rebuild the web project and test it again.

Best,

Joe

 

12/5/2009 11:11:57 AM
Gravatar
Total Posts 4

Re: authToken error when registering with RPX and Facebook

Hi Joe,

I made the change that you suggested and the server no longer throws that particular error, but registering with a Facebook account still doesn't seem to work properly. During the registration process Facebook redirects me back to my website and I am promted for an email address. When I enter the email address and click the create account button it appears as if the registration process completes and I am brought to the log in page. On this page the RPX control says "Welcome back, User." and gives me the option to sign in using my Facebook account. When I click the sign in button I am brought back to the previous OpenIdRpxHandler.aspx page and mojoPortal again asks me for my Facebook email address; and so the loop begins. I logged into mojoPortal using my administrator account and on the member list page I was able to confirm that the Facebook account is never actually added to the system. Any other suggestions? Thanks again Joe for you help.

Adam

12/6/2009 8:18:55 AM
Gravatar
Total Posts 18439

Re: authToken error when registering with RPX and Facebook

Hi Adam,

It sounds like it must be a bug but I wonder if it's a localhost issue, like maybe Facebook is trying to do a form post but can't really do that against localhost. Can you try register on this site with your Facebook account and let me know if it works or not? If not then I will investigate it as a bug.

Best,

Joe

12/7/2009 12:08:59 PM
Gravatar
Total Posts 4

Re: authToken error when registering with RPX and Facebook

Hello Joe,

I was able to register on mojoPortal.com using my Facebook account successfully, so it would appear that the problem is on my end. I have not made any changes to the code though, except the change you suggested previously, so I am still unsure as to why I would not be able to register on my own site. I know you mentioned that this might be a localhost issue, could you elaborate on that a little? Thanks again for your help.

Adam

12/7/2009 12:16:35 PM
Gravatar
Total Posts 18439

Re: authToken error when registering with RPX and Facebook

Hi Adam,

I'm not sure if it works the same or differently for different providers using RPX but if Facebook requires a form post to your site they cannot post to localhost, because localhost always refers to the current machine it is not a unique address identifying your developer machine. Any machine posting to localhost is really posting to itself. localhost is a host name that by convention on every machine under every operating system is mapped to the loopback address 127.0.0.1 so it refers every machine to itself.

This issue comes into play during development from time to time, like you cannot for example test google checkout on a localhost dev machine because google posts to the machine and it can't post to your localhost machine. So to tes it you need a dev box with a public facing ip address and host name.

If the same issue is going on with Facebook, you will find it works fine when you deploy your site to production but it just doesn't work on localhost.

Hope it helps,

Joe

12/8/2009 1:51:01 PM
Gravatar
Total Posts 4

Re: authToken error when registering with RPX and Facebook

Hello Joe,

I don't think I am having a localhost issue as the machine I am developing on has a public facing ip and host name, which I have been using to access and test mojoPortal. Also, it looks as if Facebook is posting back to my website correctly because mojoPortal reports that it was able to validate my Open ID.

I did have time to do some more debugging though and I found a line of code in the OpenIdRpxHandler.aspx.cs file that was preventing me from signing up with my Facebook and Twitter accounts. The line number is 62 (mojoPortal v. 2.3.3.0) and it reads as follows:

Response.Redirect(SiteRoot + "/Secure/Login.aspx");

Here is what I think was happening. When registering for an account via RPX, and that account needs more info (i.e. Email Address), the OpenIdRpxHandler.aspx page opens prompting the user for more info. Once the additional information had been entered, the user clicks the "Create Account" button and the page posts back to itself. On this post back, the above line redirects the user to the Login page before the account has a chance to be created. So to fix this I changed the above line to read:

if (!IsPostBack) Response.Redirect(SiteRoot + "/Secure/Login.aspx");

Joe, is this a safe change? It seems to have fixed the problem for me. Also, out of curiosity, is your copy of /Secure/OpenIdRpxHandler.aspx.cs that runs mojoPortal.com different then the copy found in version 2.3.3.0? I only ask because I am unsure why I was able to register on mojoportal.com as opposed to my own website using my facebook account.

 

Thanks for all your help,

Adam

12/9/2009 8:50:59 AM
Gravatar
Total Posts 18439

Re: authToken error when registering with RPX and Facebook

Hi Adam,

Your proposed change makes sense, I will make the same change here.

Out of curiosity, did it prompt you for additional information (email address) when you registered on this site with Facebook? It seems like the same problem should happen on this site since it has the same code.

Best,

Joe

12/9/2009 8:53:58 AM
Gravatar
Total Posts 18439

Re: authToken error when registering with RPX and Facebook

Actually my change is like this:

if (authToken.Length == 0)

{

if (Request.IsAuthenticated)

{

Response.Redirect(SiteRoot);

return;

}

 

if (!IsPostBack)

{

Response.Redirect(SiteRoot + "/Secure/Login.aspx");

return;

}

}

else

{

ProcessToken();

}

Best,

Joe

You must sign in to post in the forums. This thread is closed to new posts.