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
SwamplanderSwamplander 

Fully automating authentication with OAuth to get token and use REST API

I'm currently using the username/password authentication to get a sessionID in an app that uses the SOAP API. I'd like to move my app to REST. One thing that keeps tripping me up is that it sems like every case I've seen mentioned in the docs shows that the user always has to authenticate ON SALESFORCE.COM as part of the process. This doesn't work for me as my app runs on its own to authenticate and read/write to my SF database.

 

Is this possible with OAuth? Looking at the supported flows, every instance to me looks like you have to send the user to SF.COM to authenticate. Is this true?

Best Answer chosen by Admin (Salesforce Developers) 
SuperfellSuperfell

Interactive apps should use one of the interactive flows, but for automatied integrations its fine. 

All Answers

SuperfellSuperfell

Checkout the username/password flow for OAuth2 its logically the same as the soap login call.

SwamplanderSwamplander

Agreed... but my question is more that is this not a recommened way? Everything I see pushes you to move away from this but when you want an unattended thing to run and talk to SF, you don't have any other option, correct?

 

IOW, there's nothing wrong with this approach... correct?

SuperfellSuperfell

Interactive apps should use one of the interactive flows, but for automatied integrations its fine. 

This was selected as the best answer