Managing tokens

How to manage your tokens. Learn how to list, create and revoke tokens.

Accessing a Bytesafe registry requires a valid access token to use with the Bytesafe servers.

Authentication by running npm login will automatically store an authToken in your .npmrc file.

But teams and organizations might want to create specific tokens for CI/CD systems or for sharing.

This page describes how to:

  • Create new tokens
  • List existing tokens (created by the user)
  • Revoke tokens

Create a token

Creating a new access token for a Bytesafe registry requires a password (and prior authentication by the user).

Password is fetched from the top of the Registry page in Bytesafe.

Users should take into consideration if they want a token that is read-only or not. For example, a CI/CD environment might only require read permissions.

Read-write token

npm --registry 'https://example.bytesafe.dev/r/default/' token create

The newly created read-write token is displayed in the terminal after executing the command above and entering a valid password for the registry.

| token            | 01EPF8PPQ9WZQ5TADPCV8DPMG5       |
|------------------|----------------------------------|
| readonly         | false                            |
| cidr_whitelist   | null                             |
| created          | 2020-11-06T17:12:14Z             |

Read-only token

npm --registry 'https://example.bytesafe.dev/r/default/' token create --read-only

The newly created read-only token is displayed in the terminal after executing the command above and entering a valid password for the registry.

| token            | 01EPF8RQX26R2Q2ZCY28AP1JMH       |
|------------------|----------------------------------|
| readonly         | true                            |
| cidr_whitelist   | null                             |
| created          | 2020-11-06T17:13:21Z             |

List all tokens

To list all available tokens use the command below. The output only shows the last couple of characters of the actual token (the full token is only available on creation).

The response when executing the command also includes information regarding if the token is read-only or not.

npm token list

Example output with both read/write tokens

| id        | token           | created         | readonly  | CIDR whitelist   |
|-----------|-----------------|-----------------|-----------|------------------|
| 2b4fc6    | KMQP71...       | 2020-11-06      | no        |                  |
| 85abee    | 8DPMG5...       | 2020-11-06      | no        |                  |
| 807d1f    | AP1JMH...       | 2020-11-06      | true      |                  |

Currently Bytesafe does not support CIDR whitelist.

Revoke a token

The tokens created are long-lived and will therefore be valid until they expire.

If you want to revoke a token this is done by executing the command below. You can also remove multiple tokens by providing a list of comma separated token IDs

npm token revoke <token IDs>

Example of how to remove a token.

npm token revoke 85abee

The out put confirms the number of removed tokens

Removed 1 token

Getting access denied when trying to create or list a token?

The request is most likely not providing the access token correctly to Bytesafe. See Troubleshooting for how to resolve authentication issues.