Skip to content

Commit b800815

Browse files
karenjlijpg619dhei
authored
[docs]: Document changes for legacy token deprecation and GAT bypass 2FA configuration (#1764)
This PR addresses the following two changes related to tokens 1. Deprecation of legacy tokens 2. Addition of bypass 2FA for granular access tokens --------- Co-authored-by: Jithin Prabhakaran Girija <141764922+jpg619@users.noreply.github.com> Co-authored-by: Di Hei <dhei@github.com>
1 parent fa936bd commit b800815

File tree

5 files changed

+78
-100
lines changed

5 files changed

+78
-100
lines changed

content/integrations/integrating-npm-with-external-services/about-access-tokens.mdx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,7 @@ redirect_from:
1313

1414
An access token is an alternative to using your username and password for authenticating to npm when using the API or the npm command-line interface (CLI). An access token is a hexadecimal string that you can use to authenticate, and which gives you the right to install and/or publish your modules.
1515

16-
There are two types of access tokens available:
17-
18-
- [Legacy tokens](#about-legacy-tokens)
19-
- [Granular access tokens](#about-granular-access-tokens)
16+
As of November 2025, only [Granular access tokens](#about-granular-access-tokens) are supported. Legacy access tokens have been removed.
2017

2118
You can create access tokens to give other tools (such as continuous integration testing environments) access to your npm packages. For example, GitHub Actions provides the ability to store [secrets](https://docs.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets), such as access tokens, that you can then use to authenticate. When your workflow runs, it will be able to complete npm tasks as you, including installing private packages you can access.
2219

@@ -25,13 +22,19 @@ You can work with tokens from the web or the CLI, whichever is easiest. What you
2522
npm token commands let you:
2623

2724
- View tokens for easier tracking and management
28-
- Create new legacy tokens
25+
- Create new legacy tokens (deprecated)
2926
- Limit access according to IP address ranges (CIDR)
3027
- Delete/revoke tokens
3128

3229
For more information on creating and viewing access tokens on the web and CLI, see "[Creating and viewing access tokens][create-token]".
3330

34-
## About legacy tokens
31+
## About legacy tokens (Deprecated)
32+
33+
<Note variant="danger">
34+
35+
**Warning:** Legacy access tokens were removed on November 5, 2025.
36+
37+
</Note>
3538

3639
Legacy tokens are created with the same permissions as the user who created them. The npm CLI automatically generates and uses a publish token when you run `npm login`.
3740

@@ -52,10 +55,13 @@ Granular access tokens allow you to restrict access provided to the token based
5255
- Set a token expiration date
5356
- Limit token access based on IP address ranges
5457
- Select between **read-only** or **read and write** access
58+
- Configure a token to **Bypass 2FA** requirements
5559

5660
You can create up to 1000 granular access tokens on your npm account. You can set how long your token is valid for, at least one day in the future. Each token can access up to 50 organizations, and up to either 50 packages, 50 scopes, or a combination of 50 packages and scopes. Access tokens are tied to users’ permission; hence it cannot have more permission than the user at any point in time. If a user has their access revoked from a package or an org., their granular access token also will have its access revoked from those packages or org.
5761

5862
When you give a token access to an organization, the token can only be used for managing organization settings and teams or users associated with the organization. It does not give the token the right to publish packages managed by the organization.
5963

64+
The Bypass 2FA capability applies to tokens with write access and is set to false by default at token creation. When the Bypass 2FA option is set to true, this setting takes precedence over account-level and package-level 2FA settings. This means that even if account-level 2FA is enabled and/or package-level 2FA is required, 2FA will still be bypassed when using the token. Do not set Bypass 2FA to true if a package or organization requires fully enforced 2FA.
65+
6066
[create-token]: creating-and-viewing-access-tokens
6167
[secure-token]: using-private-packages-in-a-ci-cd-workflow#securing-your-token

content/integrations/integrating-npm-with-external-services/creating-and-viewing-access-tokens.mdx

Lines changed: 12 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -8,37 +8,6 @@ You can [create](#creating-access-tokens) and [view](#viewing-access-tokens) acc
88

99
## Creating access tokens
1010

11-
### Creating legacy tokens on the website
12-
13-
<Note>
14-
15-
**Note:** For greater security, we recommend using [granular access tokens](#creating-granular-access-tokens-on-the-website) instead of legacy read-only tokens or legacy automation tokens. For CI/CD workflows, consider using [trusted publishing](/trusted-publishers), which eliminates the need for long-lived tokens entirely.
16-
17-
</Note>
18-
19-
1. In the upper right corner of the page, click your profile picture, then click **Access Tokens**.
20-
21-
<Screenshot src="/integrations/integrating-npm-with-external-services/tokens-profile.png" alt="Screenshot of the account menu with the tokens link selected" />
22-
23-
2. Click **Generate New Token**, then select **legacy token** from the dropdown menu.
24-
25-
<Screenshot src="/integrations/integrating-npm-with-external-services/create-token.png" alt="Screenshot of the create new token button" />
26-
27-
3. (Optional) Name your token.
28-
29-
4. Select the type of access token:
30-
- **Read-only**: A read-only token can only be used to download packages from the registry. It will have permission to read any private package that you have access to. This is recommended for automation and workflows where you are installing packages, but not publishing new ones.
31-
32-
- **Automation**: An automation token can download packages and publish new ones, but if you have two-factor authentication (2FA) configured on your account, it will **not** be enforced. You can use an automation token in continuous integration workflows and other automation systems to publish a package even when you cannot enter a one-time passcode. For enhanced security in CI/CD workflows, consider using [trusted publishing](/trusted-publishers) instead, which eliminates the need for long-lived tokens.
33-
34-
- **Publish**: A publish token can perform any action on your behalf, including downloading packages, publishing packages, and changing user settings or package settings. If you have two-factor authentication configured on your account, you will be required to enter a one-time passcode when using a publish token. This is recommended for interactive workflows such as a CLI.
35-
36-
<Screenshot src="/integrations/integrating-npm-with-external-services/token-level-select.png" alt="Screenshot of the access level selection" />
37-
38-
5. Click **Generate Token**.
39-
40-
6. Copy the token from the top of page.
41-
4211
### Creating granular access tokens on the website
4312

4413
1. In the upper right corner of the page, click your profile picture, then click **Access Tokens**.
@@ -53,68 +22,46 @@ You can [create](#creating-access-tokens) and [view](#viewing-access-tokens) acc
5322

5423
4. (Optional) In the **Description** field, enter a description for your token.
5524

56-
5. In the **Expiration** field, enter a token expiration period. The date must be at least 1 day in the future.
25+
5. (Optional) Check the **Bypass two-factor authentication** checkbox if you want this token to bypass 2FA requirements for write actions.
26+
- This setting is unchecked (false) by default
27+
- By checking this box, the token will bypass 2FA for write actions even if 2FA is enabled at the account or package level
5728

58-
6. (Optional) In the **Allowed IP Ranges** field, enter IP address ranges to restrict your access token to. You must use [CIDR][cidr-wiki] notation to enter IP address ranges. To add more than one allowed IP range, click **Add IP Range** and enter an IP range in the new text field.
29+
6. In the **Expiration** field, enter a token expiration period. The date must be at least 1 day in the future.
30+
31+
7. (Optional) In the **Allowed IP Ranges** field, enter IP address ranges to restrict your access token to. You must use [CIDR][cidr-wiki] notation to enter IP address ranges. To add more than one allowed IP range, click **Add IP Range** and enter an IP range in the new text field.
5932

6033
<Screenshot src="/integrations/integrating-npm-with-external-services/granular-access-token-ip-range.png" alt="Screenshot of the allowed IP ranges section" />
6134

62-
7. (Optional) In the **Packages and scopes** section, configure your token's access to packages and scopes.
35+
8. (Optional) In the **Packages and scopes** section, configure your token's access to packages and scopes.
6336
- In the **Permissions** dropdown menu, select **No access**, **Read-only**, or **Read and write**.
6437
- Under **Select Packages**, select either:
6538
- **All Packages** to grant the token access to all packages the user account has access to.
6639
- **Only select packages and scopes** to choose up to 50 specific packages or scopes to give the token access to. Then select specific packages or scopes from the dropdown menu.
6740

6841
<Screenshot src="/integrations/integrating-npm-with-external-services/granular-access-token-packages-scopes.png" alt="Screenshot of the packages and scopes section" />
6942

70-
8. (Optional) In the **Organizations** section, configure your token's access to organizations.
43+
9. (Optional) In the **Organizations** section, configure your token's access to organizations.
7144
- In the **Permissions** dropdown menu, select **No access**, **Read-only**, or **Read and write**.
7245
- Under **Select organizations**, select the organizations you want to grant your token access to.
7346

7447
<Screenshot src="/integrations/integrating-npm-with-external-services/granular-access-token-organizations.png" alt="Screenshot of the organizations section" />
7548

7649
_**Note**: When you give a token access to an organization, the token can only be used for managing organization settings and teams or users associated with the organization. It does not give the token the right to publish packages managed by the organization._
7750

78-
9. Review the token summary, then click **Generate Token**.
51+
10. Review the token summary, then click **Generate Token**.
7952

8053
<Screenshot src="/integrations/integrating-npm-with-external-services/granular-access-token-summary.png" alt="Screenshot of the granular access token summary and the generate token button" />
8154

82-
10. Copy the token from the top of page.
55+
11. Copy the token from the top of page.
8356

8457
### Creating tokens with the CLI
8558

86-
You can create tokens with **read-only** permissions or **read and publish** permissions with the CLI.
87-
8859
<Note>
8960

90-
**Note:** You cannot create legacy automation tokens or granular access tokens from the CLI. You must use the website to generate these types of tokens. For more information, see "[Creating legacy tokens on the website](#creating-legacy-tokens-on-the-website)" and "[Creating granular access tokens on the website](#creating-granular-access-tokens-on-the-website)."
61+
**Note:** You cannot create granular access tokens from the CLI currently. You must use the website to generate these types of tokens. Support for creating granular access tokens via `npm token` CLI command will be added in the future. For more information, see "[Creating granular access tokens on the website](#creating-granular-access-tokens-on-the-website)."
9162

9263
</Note>
9364

94-
- **Read-only:** Tokens that allow installation and distribution only, but no publishing or other rights associated with your account.
95-
- **Publish:** The default setting for new tokens, and most permissive token type. Publish tokens allow installation, distribution, modification, publishing, and all rights that you have on your account.
96-
97-
In addition, you can specify that the token is only valid for a specific IPv4 address range, using [CIDR][cidr-wiki] notation. The token will only be valid when used from the specified IP addresses.
98-
99-
1. To create a new token, on the command line, run:
100-
- `npm token create` for a read and publish token
101-
- `npm token create --read-only` for a read-only token
102-
- `npm token create --cidr=[list]` for a CIDR-restricted read and publish token. For example, `npm token create --cidr=192.0.2.0/24`
103-
- `npm token create --read-only --cidr=[list]` for a CIDR-restricted read-only token
104-
2. When prompted, enter your password.
105-
3. If you have enabled [two-factor authentication][tfa], when prompted, enter a one-time password.
106-
4. Copy the token from the **token** field in the command output.
107-
108-
#### CIDR-restricted token errors
109-
110-
If the CIDR string you enter is invalid or in an inappropriate format, you will get an error similar to the one below:
111-
112-
```
113-
npm ERR! CIDR whitelist contains invalid CIDR entry: X.X.X.X./YY,Z.Z.. . .
114-
```
115-
116-
Make sure you are using a valid IPv4 range and try creating the token again.
117-
11865
## Viewing access tokens
11966

12067
<Note>
@@ -141,8 +88,7 @@ npm token list
14188

14289
- **id:** Use the token ID to refer to the token in commands.
14390
- **token:** The first digits of the actual token.
144-
- **create:** Date the token was created.
145-
- **readonly:** If yes, indicates a read-only token. If no, indicates a token with both read and publish permissions.
91+
- **created:** Date the token was created.
14692
- **CIDR whitelist:** Restricts token use by IP address.
14793

14894
[tfa]: about-two-factor-authentication

content/integrations/integrating-npm-with-external-services/revoking-access-tokens.mdx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,19 @@ redirect_from:
44
- /revoking-authentication-tokens
55
---
66

7-
To keep your account and packages secure, we strongly recommend revoking (deleting) tokens you no longer need or that have been compromised. You can revoke any token you have created.
7+
To keep your account and packages secure, we strongly recommend revoking (deleting) tokens you no longer need or that have been compromised. You can revoke any token you have created, including granular access tokens.
8+
9+
## Revoking tokens on the website
10+
11+
1. In the upper right corner of the page, click your profile picture, then click **Access Tokens**.
12+
13+
2. Find the token you want to delete in the token list.
14+
15+
3. Click the **×** button next to the token, or select multiple tokens and click **Delete Selected Tokens**.
16+
17+
4. Confirm the deletion when prompted.
18+
19+
## Revoking tokens using the CLI
820

921
1. To see a list of your tokens, on the command line, run:
1022

content/integrations/integrating-npm-with-external-services/using-private-packages-in-a-ci-cd-workflow.mdx

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,44 +25,48 @@ Create a new access token that will be used only to access npm packages from a C
2525

2626
When generating an access token for use in a continuous integration environment, we recommend using a granular access token with limited access to provide greater security.
2727

28-
If you use a legacy token instead, by default, `npm token create` will generate a token with both read and write permissions. We recommend creating a read-only token:
28+
For most CI workflows that only install dependencies and run tests, a **read-only** granular access token is sufficient and most secure.
2929

30-
```
31-
npm token create --read-only
32-
```
30+
<Note>
31+
32+
**Note:** If your CI workflow requires write operations (such as publishing test packages), you may need a granular access token with read and write permissions and bypass 2FA enabled to prevent automated workflows from being blocked by 2FA prompts. However, we strongly recommend using read-only tokens whenever possible and reserving bypass 2FA for deployment workflows only.
33+
34+
</Note>
35+
36+
<Note variant="danger">
3337

34-
For more information on creating access tokens, including CIDR-whitelisted tokens, see "[Creating an access token][create-token]".
38+
**Warning:** Legacy access tokens are removed as of November 2025.
39+
40+
</Note>
41+
42+
For more information on creating granular access tokens, including CIDR-whitelisted tokens, see "[Creating and viewing access tokens][create-token]".
3543

3644
### Continuous deployment
3745

3846
For publishing packages in continuous deployment environments, we strongly recommend using [trusted publishing](/trusted-publishers) when available, as it provides enhanced security without requiring token management.
3947

40-
If trusted publishing is not available for your CI/CD provider, you may create an [automation token][create-token] on the website. This will allow you to publish even if you have two-factor authentication enabled on your account.
48+
If trusted publishing is not available for your CI/CD provider, you can create a [granular access token with bypass 2FA enabled][create-token] on the website. This will allow you to publish even if you have two-factor authentication enabled on your account.
4149

42-
### Interactive workflows
50+
<Note>
4351

44-
If your workflow produces a package, but you publish it manually after validation, then you will want to create a token with read and write permissions, which are granted with the standard token creation command:
52+
**Security considerations for bypass 2FA:**
4553

46-
```
47-
npm token create
48-
```
54+
- Only enable bypass 2FA when necessary for automated publishing workflows
55+
- Use restrictive permissions and short expiration dates
56+
- Consider IP address restrictions and regular token rotation
57+
- Use trusted publishing instead of bypass 2FA tokens whenever possible
4958

50-
### CIDR whitelists
59+
</Note>
5160

52-
For increased security, you may use a CIDR-whitelisted token that can only be used from a certain IP address range. You can use a CIDR whitelist with a read and publish token or a read-only token:
61+
### Interactive workflows
5362

54-
```
55-
npm token create --cidr=[list]
56-
npm token create --read-only --cidr=[list]
57-
```
63+
If your workflow produces a package, but you publish it manually after validation, then you will want to create a granular access token with read and write permissions. See "[Creating and viewing access tokens][create-token]" for instructions.
5864

59-
Example:
65+
### CIDR whitelists
6066

61-
```
62-
npm token create --cidr=192.0.2.0/24
63-
```
67+
For increased security, you may use a CIDR-whitelisted granular access token that can only be used from a certain IP address range. You can configure IP address restrictions when creating your granular access token on the website.
6468

65-
For more information, see "[Creating and viewing authentication tokens][create-token]".
69+
For more information, see "[Creating and viewing access tokens][create-token]".
6670

6771
## Set the token as an environment variable on the CI/CD server
6872

0 commit comments

Comments
 (0)