Saturday, 26 January 2013

Login with Tumblr using OAuth on your Website


This script
- uses OAuth 1.0 in Java servlets to authenticate users on your website using Tumblr credentials.
- pulls the user and his blog details from its Tumblr account and displays the same on your webpage.
- has logout facility.






How to use:

The download pack contains the complete project structure with the sample war file that I have deployed in my live demo.

1. Register your domain with Tumblr

Click here to navigate to the Tumblr registration page and create a new App.



Then fill up your application details as shown. Save.
If you deploy the same war file provided by me, then just change your domain name in place of "example.com". The callback URL points to a servlet in the WAR file.





Your application will be created and you will be provided with an OAuth Consumer Key and a Consumer Secret.



3. Web.xml (Input variables)

Specify these Consumer Key and Consumer secret in your web.xml

After successful login welcome.jsp will be shown to the user.



3. Welcome.jsp (Output variables)

The user account details will be available as session attributes in welcome.jsp
The object tumblrUser contains these attributes as shown. The blogList attribute is an arraylist containing data about each blog the logged in user has created. You may write your own display code instead, as required.


Thanks!

2 comments:

  1. Fantastic tutorials. So easy to follow and your explanations are great. I got Tumblr integration with my site working easily with these.

    ReplyDelete
    Replies
    1. Thanks buddy .. we make a point to keep things simple :)

      Delete