How to Generate a Salesforce Access Token
Airflow requires an access token to connect to a Salesforce environment. This guide walks through how to generate one.
Prerequisites
- Install the Salesforce CLI
- An account with access to Salesforce
Steps
- When logging in the for the first time, run this command in the terminal:
sf org login web --instance-url "<YOUR_SF_INSTANCE_URL>"
YOUR_SF_INSTANCE_URL will look something like https://something.my.salesforce.com or https://something--dev.sandbox.my.salesforce.com
It will ask you to enter an MFA code at a verification url. You might have to login once you visit the url. Follow the instructions and return to the SF CLI window. It will say the login was successful.
- Once that's set up, run this command to generate a key:
sf org display --target-org "<YOUR_LOGIN_USERNAME>"
It will show a chart with an access token, which should be a long hash. Set that as the salesforce_access_token variable in airflow.
NOTE: You will only need to run step 1. once. If your token expires, you can just rerun step 2.