Newer Version Available
Use an Existing Access Token Instead of Authorizing
When you authorize into an org using the auth
commands, the Salesforce CLI takes care of generating and refreshing all tokens, such as the
access token. But sometimes you want to run a few CLI commands against an existing org without
going through the entire authorization process. In this case, you must provide the access token
and instance URL of the org.
-
Use config:set to set the instanceUrl config value to the Salesforce instance that hosts
the existing org to which you want to connect.
1sfdx config:set instanceUrl=https://na35.salesforce.com -
When you run the CLI command, use the org’s access token as the value for the --targetusername parameter rather than the org’s username.
1sfdx force:mdapi:deploy --deploydir <md-dir> --targetusername <access-token>
The CLI does not store the access token in its internal files. It uses it only for this CLI command run.