Skip to content Skip to sidebar Skip to footer

Openid And Facebook Authentication In Webapp Running On Localhost

My java/javascript web application is in development, and I hava a javascript application that communicates with my database (where I maintain my own userids) using ajax POST comma

Solution 1:

Facebook OAuth works with localhost apps. This is because Facebook redirects the browser to the redirect_uri you supply in oauth, your browser knows where http://localhost is (I actually used a virtual host in apache & windows vhosts, don't know if you can enter localhost as website url in your app settings). Works perfectly

Google Oauth however, in my experience, doesn't work on local version. Somehow the site needed to be accessible from Google itself (not just the browser) for this to work, and it didn't, so it doesn't (I don't remember the exact details, sorry)

Don't know about the others

Solution 2:

You could add DNS entries on your local machine so that mysite.com resolves to your local computer. By doing this, you will be able to login from your local machine to do your tests.

In Windows, you can do this by editing the file: C:\Windows\System32\drivers\etc\hosts

Add a new line:

127.0.0.1 mysite.com

Regarding OpenID, I am not sure if would accept logins from localhost URLs, but it will surely work after adding the entry in the hosts file and having a proper domain (even though it RESOLVES only on your computer).

The trick is that after login, Facebook or Google responds to your application with something like this: redirect the user to mysite.com as authenticated. Your browser then will resolve mysite.com as your machine and it is all working.

Post a Comment for "Openid And Facebook Authentication In Webapp Running On Localhost"