Use an Existing Access Token

When you authorize an org using the org login commands, 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 provide the access token and URL of the Salesforce instance that hosts the org to which you want to connect.
Almost all CLI commands that have the --target-org | -o flag accept an access token. The only exception is org display user.
  1. Open a terminal (macOS and Linux) or command prompt (Windows).
  2. Run the org display command to get the instance URL for the org to connect to. See the value for the Instance Url key.
  3. Run the org auth show-access-token command to get the access token.
  4. Use config set to set the org-instance-url configuration variable. To set it locally, run the command from a Salesforce DX project; to set it globally, use the --global flag.
  5. When you run the CLI command, use the org’s access token as the value for the --target-org flag rather than the org’s username. For example:

    If your access token contains a ! character, you must sometimes escape it with a backslash (\). For example, if your access token is 00007wpr!AQkAQA, specify it this way: --target-org 00007wpr\!AQkAQA

    Tip

Salesforce CLI doesn’t store the access token in its internal files. It uses it only for this CLI command run.