简体   繁体   中英

Extracting OAuth token from Salesforce Workbench to do Rest Api calls

I am new to Salesforce and SF workbench.

I have been given read access and login credentials to the SF workbench for one of out clients.

I know I can use SF Rest API to extract data from Salesforce object, but I guess I would need OAuth token to be able to do that.

Is there a way to extract those tokens from the workbench to do simple rest api curl commands?

If you setup a Connected App in Salesforce (any org, including a developer org ) and enable OAuth then you can use the following curl command to create an OAuth token from a username and password:

curl https://login.salesforce.com/services/oauth2/token \
  -d "grant_type=password" \
  -d "client_id=YOUR_OAUTH_CONSUMER_KEY" \
  -d "client_secret=YOUR_OAUTH_CONSUMER_SECRET" \
  -d "username=YOUR_USERNAME" \
  -d "password=YOUR_PASSWORD"

From Workbench if you select Session Information from the Info menu and expand the Connection folder you will see a Session Id value this is your current session token and it can be used for Curl REST commands.

You could also use the REST Explorer found under the Utilities menu to do your simple REST API commands.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM