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
dai developerdai developer 

oAuth as a client

Hello,

I´ve to make a little funcionality where oAuth is used and after googling it I don´t know if I have an enormous problem or not problem at all.

Every information I find is related to authentication from the salesforce side but what I have to do is authenticate an external callout with an external oAuth endpoint.

It can be resumed this way:

External someone call myHttpPOST apex class method(which NOT includes oAuth flow)

This external wants me to authenticate his request so gives me an oAuth Url which I´ll have to request(POST ay ay), depending of the response, I´ll generate an adecuate response to the original request to my POST apex rest.

Then, I´ll have a POST apex method which receive a request and inside of my method I´ll have to make a POST request to an external URL because cannot have two apex post methods in the same class.

As I said, I´m not sure if I understood a word or I´m finding problems where there are not.

Thanks, regards

 
Best Answer chosen by dai developer
KevinPKevinP
Making an Authenticate oAuth call from within Salesforce to a third party server is definitely doable! I've done it a number of times. 

That said, Oauth is a complicated and detail oriented protocol. I highly suggest reading through the oAuth documentation at: http://oauth.net/

To help you get started, there is an "oauth playground" unmanaged package you can install from here: https://github.com/jesperfj/sfdc-oauth-playground 

While that app is setup to help you make oAuth calls, the code is an excellent starting point for creating your own oAuth library focused for your needs.

All Answers

KevinPKevinP
Making an Authenticate oAuth call from within Salesforce to a third party server is definitely doable! I've done it a number of times. 

That said, Oauth is a complicated and detail oriented protocol. I highly suggest reading through the oAuth documentation at: http://oauth.net/

To help you get started, there is an "oauth playground" unmanaged package you can install from here: https://github.com/jesperfj/sfdc-oauth-playground 

While that app is setup to help you make oAuth calls, the code is an excellent starting point for creating your own oAuth library focused for your needs.
This was selected as the best answer
dai developerdai developer
That makes me feel more confident about deadlines Kevin, plus the code, much obliged!!

Regards