Authenticate to use the CLI
How to authenticate the Snyk CLI after installation
PreviousUsing CLI releases before version 1.1230.0 on an Apple M1 or M2 machineNextUpgrade the Snyk CLI
Last updated
Was this helpful?
How to authenticate the Snyk CLI after installation
Once you have installed the Snyk CLI using your chosen tool or operating system (OS), you need to authenticate with your Snyk account.
Snyk supports the following authentication methods:
OAuth 2.0
Personal Access Token (PAT)
Snyk API token
If your Snyk account is hosted on a SNYK-US-02, SNYK-EU-01, or SNYK-AU-01 endpoint rather than the default SNYK-US-01 endpoint, you need to configure the CLI environment before you authenticate with your Snyk account.
To do this, run the environment config command:
snyk config environment <ENVIRONMENT_NAME>This example specifies the SNYK-EU-01 environment:
snyk config environment SNYK-EU-01Once the environment has been configured, authenticate using your preferred method.
This applies to: Homebrew, npm, Yarn, Scoop (Windows), and Direct binary downloads (standalone executables).
Run the following command:
A browser window will open on a Snyk address. Click Authenticate.
Return to your terminal. You should see the message Your account has been authenticated.
For local service account testing, use the command:
To authenticate in the terminal and save the profile locally, run the command:
Add your PAT or API token to the Snyk CLI configuration using the snyk config command:
You can export local tokens to your local shell profile using the command:
Or run them for each command using:
Pass your chosen token into the container using Docker's environment flag during execution:
This applies to: general CI/CD Pipelines (Jenkins, GitLab, CircleCI, and so on) and GitHub Actions.
Map your securely stored PAT or API token to the SNYK_TOKEN environment variable, or map your OAuth token to SNYK_OAUTH_TOKEN, directly within your pipeline configuration or GitHub Actions env block.
Last updated
Was this helpful?
Was this helpful?
snyk auth snyk auth --auth-type=oauth --client-id=<ID> --client-secret=<SECRET>snyk auth <YOUR_PAT>snyk auth <YOUR_API_TOKEN>snyk config set api=<YOUR_PAT_OR_API_TOKEN>export SNYK_TOKEN=<YOUR_PAT_OR_API_TOKEN>SNYK_TOKEN=<TOKEN> snyk <COMMAND>docker run -e SNYK_TOKEN=<YOUR_PAT_OR_API_TOKEN> ...docker run -e SNYK_OAUTH_TOKEN=<YOUR_OAUTH_TOKEN> ...
