# Visual Studio extension authentication

To scan your Projects you must authenticate with Snyk.&#x20;

{% hint style="warning" %}
Before authenticating, be sure you have set your region properly. For details, see [Regional hosting and data residency](../../../working-with-snyk/regional-hosting-and-data-residency), which has the [list of regional URLs](../../../../working-with-snyk/regional-hosting-and-data-residency#regional-urls).
{% endhint %}

Snyk supports the following protocols for authentication:

* OAuth 2.0 (default)
* Snyk API token (fallback option)

## Steps to authenticate using the OAuth 2.0 protocol

To authenticate follow these steps:

1. After the extension is installed, navigate to **Extensions** , **Snyk**, **Windows**, and then **Snyk** to open the Snyk panel.&#x20;

<figure><img src="https://2533899886-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MdwVZ6HOZriajCf5nXH%2Fuploads%2FvzWIOTX9RXxX4DVUPFTP%2FSCR-20240822-llxy.png?alt=media&#x26;token=6c38d20b-1d43-4cf0-b1ed-c2881cfe517f" alt="Snyk extension navigation" width="563"><figcaption><p>Snyk extension navigation</p></figcaption></figure>

2. On the welcome screen, click **Trust project and scan.**

<figure><img src="https://2533899886-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MdwVZ6HOZriajCf5nXH%2Fuploads%2FqTGGVLQGESiQWGFj6LCt%2FSCR-20240822-lmdw.png?alt=media&#x26;token=97359525-686d-4c6b-bf09-390e25dbd9b8" alt="Trust project and scan" width="563"><figcaption><p>Trust project and scan</p></figcaption></figure>

3. The extension opens a new page in a browser and asks you to log in to your Snyk account:

<figure><img src="https://2533899886-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MdwVZ6HOZriajCf5nXH%2Fuploads%2FuJIIqXr8i3KqhoEO15rl%2FSCR-20240821-qogt.png?alt=media&#x26;token=abb4fa92-53ea-4d10-bad5-0b6f46eee9e1" alt="Snyk login" width="375"><figcaption><p>Snyk login</p></figcaption></figure>

4. The next page asks for your authorization for the IDE to act on your behalf. Click **Grant app access**.

<figure><img src="https://2533899886-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MdwVZ6HOZriajCf5nXH%2Fuploads%2FMJFAK5Z7El4iwNgTpeC3%2FSCR-20240821-qnpy.png?alt=media&#x26;token=fc7df895-8bf4-4a5a-8682-2355df1cd921" alt="Grant app access" width="375"><figcaption><p>Grant app access</p></figcaption></figure>

5. After you authenticate successfully, view the confirmation message.

<figure><img src="https://2533899886-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MdwVZ6HOZriajCf5nXH%2Fuploads%2FyPOisvpzyLdvxhFsnZfm%2FSCR-20240821-qrgp.png?alt=media&#x26;token=05c46314-750c-45d8-9c8e-1ad8906f6eba" alt="Successful authentication" width="375"><figcaption><p>Successful authentication</p></figcaption></figure>

5. The IDE reads and saves the authentication on your local machine. Close the browser window and return to the IDE.

The analysis starts automatically. If you have problems, see [OAuth 2.0 authentication does not work](../troubleshooting-ides/how-to-set-environment-variables-by-operating-system-os-for-ides-and-cli-1).

{% hint style="info" %}
OAuth 2.0 tokens are not static and cannot be copied from Snyk account page.
{% endhint %}

## Steps to authenticate using your Snyk API token

{% hint style="warning" %}
This method is inferior to the OAuth method.
{% endhint %}

To authenticate follow these steps:

1. After the extension is installed, navigate to **Extensions,** **Snyk**, and then **Settings**:

<figure><img src="https://2533899886-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MdwVZ6HOZriajCf5nXH%2Fuploads%2FKTpUk4YWn5AhLBsbI8SL%2FSCR-20240822-lyzs.png?alt=media&#x26;token=1819c32b-436f-4979-b704-cdf2c1af7946" alt="Snyk Settings navigation" width="375"><figcaption><p>Snyk Settings navigation</p></figcaption></figure>

2. Find the **Authentication Method** and change it to **Token authentication**
3. Copy your API token. For details, see [Obtain and use your Snyk API token](../../../../getting-started#obtain-and-use-your-snyk-api-token).
4. Be sure to use your personal token.  Paste or enter the token in the **Token** field.
5. Click **OK.**&#x20;

## How to switch accounts

To re-authenticate with a different account, follow these steps:

1. Navigate to **Extensions > Snyk > Settings.**
2. Clear the value of the **Token** field.
3. Click **OK**.
4. When you have logged out, start authentication from scratch.
