2

If I want my application to process jobs and send API REST requests to my APEX endpoints, which OAuth2 authorization/grant method should I use?

  • If I use authorization_code, then the browser needs to redirect (to Salesforce login page) and the user needs to confirm access. (This would be wrong right?).

I think that I would want to use grant_type : password

If I use password, then I can just set my organizations administration username and password in my application and use that.

I plan on batching up some requests and sending through gearman as a background process.

1 Answer 1

2

I solved with this approach:

  1. use grant_type = authorization_code the first time and ACCESS_TYPE=offline.
  2. save the AccesToken and the RefreshToken in a custom setting.
  3. Start the background job and everytime the job starts, ask for a new token using the refresh token and grant_type = refresh_token.

You have all the documentation in google to do this. https://developers.google.com/accounts/docs/OAuth2WebServer?hl=es Look for "Using a refresh token"

1
  • If you save the token, do you also save the instance URL that you should be using to send your REST requests?
    – Layke
    Feb 25, 2014 at 11:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .