+ Start a Discussion
Benjamin VisonBenjamin Vison 

How to automatically authorize an application without user interaction

I am trying to setup the OAuth process to get the access_token, specifically in PHP using this example (http://developer.force.com/cookbook/recipe/interact-with-the-forcecom-rest-api-from-php). However, I don't know how to avoid the "Allow Access" page that shows up, I would like to be autimatically allowed so the application can continue and get the access_token... It would be a pain to have to manually allow access on every system I am planning on implementing this integration.. What am I missing?
Best Answer chosen by Benjamin Vison
Girish P
I dont know much about PHP, i am posting generic CURL statement that will be hlepful to understand.
  • Use Username and passwords to login to saleforce and get the access token, which when appended with REST calls to salesforce will give data back.For this someone has to create an App inside Salesforce whic will provide client secret and ID
curl https://<instance>.salesforce.com/services/oauth2/token -d "grant_type=password" -d "client_id=myclientid" -d "client_secret=myclientsecret" -d "mylogin@salesforce.com" -d "password=mypassword123456"

This will return JSON format data which will contain acceess_token to be used for further calls. and than use REST URL as follows

curl https://instance_name.salesforce.com/services/data/v38.0/ -H "Authorization: Bearer "THIS_IS_THE_ACCESS_TOKEN_RECEIVED_EARLIER>"
note - https://instance_name.salesforce.com/services/data/v38.0/  is the REST endpoint, i you have REST endpoints for salesforce you can replaces it as needed.