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.

Popular posts from this blog

Brain Error: No space left on device

I'm not dumb. I just have a command of thoroughly useless information.
Calvin - It's a Magical World, Bill Waterson
Wired's June 2008 edition included an article entitled 'Quiet Please: how Man-made noises may be altering Earth's ecology'.

The article focused on the theory put forward by Bernie Krause, a field recording scientist, that nature's soundtrack (biophony) is being adversely affected by a louder human-made cacophony (anthrophony). Krause postulates that the animal kingdom divides the acoustic spectrum so it's inhabitants do not interfere with each other. However, human-made noise is increasingly disrupting this harmony and intrudes on a piece of the spectrum already in use - drowning out natures voice.

As an example, Krause summizes that the rapidly declining population of the Yosemite spadefoot toad is due to the noise generated from low-flying military aircraft, performing training exercises in the area. Coyotes and owls are able to home in on i…

If This, Then What?

Imagine that you could combine services (internet and otherwise) together like Lego blocks to create new, personalised services.

If This, Then That (ifttt) is a new service that allows you to do just that.

Through an intuitive interface ifttt puts the power of "Event Driven Programming" at your fingertips, letting you connect services with digital duct tape. Event driven programming can be simply broken into two stages - event selection/detection followed by event handling. ifttt terms these stages as triggers and tasks and provides a comprehensive list of services that you can target as a trigger or task, from Facebook and Twitter through to Google calendar events.

For example, it is possible to build a service that will send a text to your mobile phone (task) if the weather service has forecast rain for the following day (trigger). The mechanism for building such a service is so simple and straight-forward that no programming knowledge is required. Trigger and task construc…