Skip to main content

Local Testing OAuth Social Signin

On some recent Grails projects, I have been looking at using the Twitter and Facebook OAuth signin process.

This process allows you to authenticate users based on their Twitter/Facebook logins, without the need for the user to expose their passwords to your site.

When you create your 'application' within Twitter or Facebook, it is necessary to define the URL where the application can be accessed. Twitter and Facebook will only redirect to this URL during the authentication process.

I have tested running some applications on Heroku or Appfog, with Twitter and Facebook happy to redirect to the appropriate URLs with successful authentication.

However, when testing locally, I follow these steps to work through the authentication process.

1. App Context
Ensure that the Grails app context is '/' - as the application is generally deployed this way on Heroku/Appfog:

Config.groovy

grails.app.context = '/'


2. Port Binding:
While the local application will generally run on port 8080, we want it accessible via port 80 - as it is run on Heroku and Appfog. One method of achieving this locally is to bind the ports as follows

sudo ssh -L 80:localhost:8080 root@localhost

Note: if you are working on a Mac - ensure that Remote Login is enabled also.

If you application is running via HTTPS (port 8443), the following port forward command is required:

sudo ssh -L 443:localhost:8443 root@localhost

3. Hosts
Edit the /etc/hosts file in order to redirect calls to your Heroku/Appfog application URL to your localhost:

/etc/hosts

127.0.0.1 murmuring-gorge-6675.herokuapp.com

4. Test the Process
Now, running the application on your local machine, it should be possible to follow the Twitter/Facebook OAuth process, with all interaction taking place with your local server.

Comments

Popular posts from this blog

Let your Confluence Tweet!

The single biggest problem in communication is the illusion that it has taken place. George Bernard Shaw The recent Atlassian Codegeist competition afforded me an opportune moment to further explore new areas of Confluence plugin development. My current contracting assignment involves heavily customising both the theme and functionality of the Confluence platform - but Codegeist offered a chance to really experiment! With the explosion of social networking applications and the rise of the flow , I decided to integrate the functionality of one of the most profilic flow tools in the netsphere, Twitter , with Confluence. Twitter + wiki = Twikkir Posing the simple question 'What are you doing now?", millions have taken to tweeting their response on Twitter to anybody who will listen. From a simple status update to a possible support circle to a tribe building ecosystem , Twitter has become another pillar of the fast-evolving web. In his blog, Rands notes: I want to

Explore. Dream. Discover. Be Interesting.

Interesting 2008 Bunting and all ... Twenty years from now you will be more disappointed by the things that you didn’t do than by the ones you did do. So throw off the bowlines. Sail away from the safe harbor. Catch the trade winds in your sails. Explore. Dream. Discover. Mark Twain Over the weekend, my wife and I attended Interesting 2008. The concept of the event - to gather a number of speakers to talk about something they are interested in - was intriguing and all reports suggested it would be a Saturday well spent. Comparisons with the TED talks certainly helped to pique my interest and we were most definitely not disappointed. Russell Davies , the coordinator of the day, has this to say about being 'interesting': The way to be interesting is to be interested. You’ve got to find what’s interesting in everything, you’ve got to be good at noticing things, you’ve got to be good at listening. If you find people (and things) interesting, they’ll find you inter