Instagram OAuth authentication with Groovy

We’re big fans of Instagram over at groovy.io so I decided to start work on a Groovy Instagram client library called groovy-instagram. Instagram played a big part in the very first Grails48 hackathon with pictures being taken and shared from teams across the world.

The library is brand new but there is enough good stuff in there now to get ya going. In this article we are going to cover OAuth authentication requests on behalf of an end user. For the purposes of this article we are going to assume you have registered your client app and callback URL with Instagram and have your client_id and client_secret. To get rollin just drop the groovy-instagram.jar file in the lib folder of your Grails app.

Authenticating a user with Instagram is a 3 step process that is easily explained in the following sample Grails controller. The Instagram client_id, client_secret, and callback url have been defined in my Config.groovy file.

After step 1 the user will be redirected to an Instagram login page.

Once authenticated Instagram will call your callback url with a code that is used in step 3.

And that’s all there is to it. Stay tuned for more articles on accessing various Instagram API functionality through the groovy-instagram library.

Cheers,
Jeff

Orignally posted Nov 25, 2012 on Posterous