Using the Salesforce.com OAuth Playground

July 28th, 2010

My article on developer.force.com, Using OAuth to Authorize External Applications, shows how to develop external Java applications that use OAuth to access your Saleforce.com data. But what if you want to do the opposite? What if you need to write an application on the Force.com platform that uses your data from Google, Twitter, LinkedIn or TripIt using OAuth? Luckily Jesper Jorgenson at Salesforce.com posted an open source project called sfdc-oauth-playground which is a generic consumer implementation of OAuth as a Force.com App.

The main purpose of this beta project is to show you how to write OAuth signed requests in Apex. There is a managed packaged you can install into your org but if you really want to dig into the guts of OAuth (and who doesn’t??) you’ll need to download and install the source code from the project. The managed package doesn’t afford you to opportunity to modify code or view granular debug statements.

Jesper doesn’t provide much documentation for the project so I’ve put together a short video showing how to get started using Google Accounts and Blogger. Unfortunately different providers implement OAuth to their own liking so you sometimes have to make modifications to the requests being sent over the wire. I ran into a number of issues so hopefully this will assist you in getting up and running with OAuth.

 

In case you don’t have time for the video, here are a couple of screenshots outlining the process using the OAuth Consumer Playground application from the managed package.

Create a new OAuth Service (e.g., Blogger) with various URLs for accessing services

oauth-service-unauthorized.png

 

Authorize Salesforce access to Blogger

oauth-service-preauth.png

 

Grant access to Blogger

oauth-service-blogger.png

 

Authorization confirmation

oauth-service-auth.png

 

OAuth Service access tokens

oauth-service-authorized.png

 

Testing the service

oauth-service-test.png

Categories: Apex, Salesforce

Leave a comment

Comments Feed9 Comments

  1. kaushik

    Hello Jeff,
    The oauth playground doesnot seem to work with tripit have you tried with tripit oauth services.
    regards
    kaushik

  2. Jeff Douglas

    What version of OAuth does Tripit use? The OAuth playground is 1.0.

  3. Osama

    Have you tried it with elance API?

  4. Osama

    There is an issue with elance API which is in beta phase right now.

    Thanks for the awesome post, Jeff!

  5. Joel

    Thanks for the post and video. Could you point me to any articles about using the OAuth Consumer Playground package within triggers? Specifically, I’d like case closure to trigger a request to an external applications.

  6. balt

    I’m receiving http error 403 = Forbidden. Have you ever seen that kind of error?

  7. balt

    is it possible to add more than one header into request? I’m trying to connect Concur project which expects not only authorization header, by adding 3 headers and it doesn’t work.

  8. sreenath

    Hi Jeff,
    Thank you very much for this post. it helps me alot.
    I have one doubt, how to get the id values of your blog shown in the video passed in saved url’s. please provide code for to get that one.

  9. Nik's

    Thank you for the article… it helps me lot….

Leave a comment

Feed

http://blog.jeffdouglas.com / Using the Salesforce.com OAuth Playground

WordPress Appliance - Powered by TurnKey Linux