Programming

Digg oAuth using Scribe

I really like the library for doing oAuth in Java. It uses a fluent API, a very slim dependency structure, and is ready to use in android apps. So, when I needed to connect to Digg’s API for a Java app, I looked at Scribe first. Unfortunately, Scribe doesn’t support Digg out of the box (it does however, support Facebook, Yahoo, FourSquare, Vimeo, and many others). Adding support for a new service is simple. Lets start with a sample client application: Simple enough – pay special attention to line 18. This is scribe’s fluent api for setting up the oAuth provider. After that, we have a pretty simple workflow – get a request token, ask the user to authorize the application, and trade the request token in for an access token. The code to make this all work is even easier. Scribe provides 2 base classes – DefaultApi10a and DefaultApi20 (for oAuth v1.0a and oAuth v2 respectively). Since Digg’s api uses oAuth v1, we just extend DefaultApi10a and plug in the right info, like so: Thats it, we’re done. You can get the code


Leave a Reply

Your email address will not be published. Required fields are marked *