function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

OAuth for Apex



Is there a library or implementation of OAuth protocol using Apex?


I'm writing OAuth Consumer using Apex and Visualforce pages but faced several issues:


  * HTTP Redirect function, message-passing using HTTP header etc.

  * Session management (Cookie, Session ID, Session Object etc.)

  * Nonce generation


I appreciate your help.




Best Answer chosen by Admin (Salesforce Developers) 

Been working on something like this and just posted some code you may be able to use:


All Answers

check out the release notes for teh Winter '10 release.  I did se a mention for OAuth in there.

Thanks, Paul!


I found Support of OAuth from Winter '10 release note.


I can't wait the release, although, so is there a way to use early test-version of Winter '10, or OAuth library implemented by Apex?


Remote Access is in Winter '10, but isn't available until October 12th, when we complete the staggered rollout of the release.  




Dapkus, do you know whether Apex can act as OAuth consumer ?

Reading winter '10 release note, it seems that Salesforce can act as OAuth service provider for remote access applications, but not mentioned about OAuth consumer.


In Winter '10, we're adding Service Provider support for OAuth.    I believe we have the building blocks to allow you to implement an OAuth client, with Apex and VisualForce, but you'd have to build it yourself today. 


Are you looking for an OAuth library for Apex or are you asking for something like Google's OAuth proxy?




Hi Pete,


I think Shinichi is asking for an OAuth library so that you could sign requests in Apex (or at least that's what I'm looking for!).


Will this be available in this release or do we have to roll our own using the Crypto library?


Yes, if you have special support for OAuth in Apex, or even OSS project which trying to build the feature, it would be nice news for me, too. Building from crypto is a little messy and waste of time if they already have.


I'm not expecting OAuth proxy feature (like iGoogle is providing for gadgets) but if you can provide it would be great.


By the way, in the release note, it is written that OAuth SP feature is going to be available after 12 October, 2009, but not yet AFAIK. Does anyone know the status of this feature's availability ?


Hi Shin,


Where you able to find something on oauth for salesforce as consumer.

Do let me know if you have implemented it.




Been working on something like this and just posted some code you may be able to use:


This was selected as the best answer



Is there an official solution to this yet? The library mentioned here is exactly what I'm looking for, but it's still in beta and I would like a stable supported one.


Otherwise, is there a native/simpler way to sign oAuth requests in Apex?






There is nothing native in Apex yet.


But this library is stable in the sense that I haven't touched it for 1 1/2 years :-).