jpg619/version-bump-tar-2
@reggi/path-to-regexp
dependabot/npm_and_yarn/main/copy-to-clipboard-4.0.2
dependabot/npm_and_yarn/main/eslint-10.4.0
dependabot/npm_and_yarn/main/npmcli/eslint-config-7.0.0
dependabot/npm_and_yarn/main/proc-log-7.0.0
dependabot/npm_and_yarn/npm_and_yarn-826852524d
dependabot/npm_and_yarn/npm_and_yarn-ab9a7f4bc2
deprecate-totp-2fa
dhei/classic-tokens
gat-bypass-2fa-docs
jpg619/fix-accessibility-content-flow
jpg619/version-bump-tar-2
kartykp/gat-bypass-2fa-docs
kartykp/upgrade-path-to-regex
main
maitxn/version-bump-tar
patch-1
reggi/cache-based-on-version
reggi/dev-engines
reggi/fix-transform-prettier
reggi/overrides
update-search-sensitivity
| 1 | --- |
| 2 | title: Creating and viewing access tokens |
| 3 | redirect_from: |
| 4 | - /creating-and-viewing-authentication-tokens |
| 5 | --- |
| 6 | |
| 7 | You can [create](#creating-access-tokens) and [view](#viewing-access-tokens) access tokens from the website and command line interface (CLI). |
| 8 | |
| 9 | ## Creating access tokens |
| 10 | |
| 11 | ### Creating granular access tokens on the website |
| 12 | |
| 13 | 1. In the upper right corner of the page, click your profile picture, then click **Access Tokens**. |
| 14 | |
| 15 | <Screenshot src="/integrations/integrating-npm-with-external-services/tokens-profile.png" alt="Screenshot of the account menu with the tokens link selected" /> |
| 16 | |
| 17 | 2. Click **Generate New Token**. |
| 18 | |
| 19 | <Screenshot src="/integrations/integrating-npm-with-external-services/create-token.png" alt="Screenshot of the create new token button" /> |
| 20 | |
| 21 | 3. In the **Token name** field, enter a name for your token. |
| 22 | |
| 23 | 4. (Optional) In the **Description** field, enter a description for your token. |
| 24 | |
| 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 |
| 28 | |
| 29 | 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. |
| 30 | |
| 31 | <Screenshot src="/integrations/integrating-npm-with-external-services/granular-access-token-ip-range.png" alt="Screenshot of the allowed IP ranges section" /> |
| 32 | |
| 33 | 7. (Optional) In the **Packages and scopes** section, configure your token's access to packages and scopes. |
| 34 | - In the **Permissions** dropdown menu, select **No access**, **Read-only**, or **Read and write**. |
| 35 | - Under **Select Packages**, select either: |
| 36 | - **All Packages** to grant the token access to all packages the user account has access to. |
| 37 | - **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. |
| 38 | |
| 39 | <Screenshot src="/integrations/integrating-npm-with-external-services/granular-access-token-packages-scopes.png" alt="Screenshot of the packages and scopes section" /> |
| 40 | |
| 41 | 8. (Optional) In the **Organizations** section, configure your token's access to organizations. |
| 42 | - In the **Permissions** dropdown menu, select **No access**, **Read-only**, or **Read and write**. |
| 43 | - Under **Select organizations**, select the organizations you want to grant your token access to. |
| 44 | |
| 45 | <Screenshot src="/integrations/integrating-npm-with-external-services/granular-access-token-organizations.png" alt="Screenshot of the organizations section" /> |
| 46 | |
| 47 | _**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._ |
| 48 | |
| 49 | 9. In the **Expiration** field, select a token expiration period from the dropdown menu. You can choose from predefined options or select Custom to specify a custom expiration date using the date picker. |
| 50 | |
| 51 | _**Note**: The date must be at least 1 day in the future._ |
| 52 | |
| 53 | 10. Review the token summary, then click **Generate Token**. |
| 54 | |
| 55 | <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" /> |
| 56 | |
| 57 | 11. Copy the token from the top of page. |
| 58 | |
| 59 | ### Creating tokens with the CLI |
| 60 | |
| 61 | <Note> |
| 62 | |
| 63 | **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)." |
| 64 | |
| 65 | </Note> |
| 66 | |
| 67 | ## Viewing access tokens |
| 68 | |
| 69 | <Note> |
| 70 | |
| 71 | **Note:** Full tokens are never displayed, only the first and last four characters will be shown. You can only view a full token immediately after creation. |
| 72 | |
| 73 | </Note> |
| 74 | |
| 75 | ### Viewing tokens on the website |
| 76 | |
| 77 | To view all tokens associated with your account, in the upper right corner of the page, click your profile picture, then click **Access Tokens**. |
| 78 | |
| 79 | <Screenshot src="/integrations/integrating-npm-with-external-services/tokens-profile.png" alt="Screenshot of the account menu with the tokens link selected" /> |
| 80 | |
| 81 | ### Viewing tokens on the CLI |
| 82 | |
| 83 | To view all tokens associated with your account, on the command line, run the following command: |
| 84 | |
| 85 | ``` |
| 86 | npm token list |
| 87 | ``` |
| 88 | |
| 89 | #### Token attributes |
| 90 | |
| 91 | - **id:** Use the token ID to refer to the token in commands. |
| 92 | - **token:** The first digits of the actual token. |
| 93 | - **created:** Date the token was created. |
| 94 | - **CIDR whitelist:** Restricts token use by IP address. |
| 95 | |
| 96 | [tfa]: about-two-factor-authentication |
| 97 | [cidr-wiki]: https://en.wikipedia.org/wiki/Classless_Inter-Domain_Routing |