You can create and view access tokens from the website and command line interface (CLI).
In the upper right corner of the page, click your profile picture, then click Access Tokens.
Click Generate New Token.
In the Token name field, enter a name for your token.
(Optional) In the Description field, enter a description for your token.
(Optional) Check the Bypass two-factor authentication checkbox if you want this token to bypass 2FA requirements for write actions.
(Optional) In the Allowed IP Ranges field, enter IP address ranges to restrict your access token to. You must use CIDR 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.
(Optional) In the Packages and scopes section, configure your token's access to packages and scopes.
(Optional) In the Organizations section, configure your token's access to organizations.
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.
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.
Note: The date must be at least 1 day in the future.
Review the token summary, then click Generate Token.
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."
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.
To view all tokens associated with your account, in the upper right corner of the page, click your profile picture, then click Access Tokens.
To view all tokens associated with your account, on the command line, run the following command:
npm token list