Introduction
This article shows how to generate an access token in the JFrog Platform. You can create a token from the JFrog Platform UI, from the REST API using an existing token, or from the REST API using your username and password.
Prerequisites
-
Only a platform administrator can create admin-scoped tokens. Non-admin users can create Identity Tokens (user scope) for themselves.
-
To use the REST API with a Bearer token, you need an existing valid access token.
-
To use the REST API with basic authentication, the Enable Token Generation via API setting must be enabled (token.allow-basic-auth). See Method 3.
Step-by-step
Choose the method that matches your situation, then follow that method only.
Method
|
Requires an existing token
|
Requires the UI
|
Method 1: JFrog Platform UI
|
No
|
Yes
|
Method 2: REST API with a Bearer token
|
Yes
|
No
|
Method 3: REST API with basic authentication
|
No
|
No
|
If you are bootstrapping a CI/CD pipeline, also consider OpenID Connect (OIDC), which exchanges a short-lived identity token issued by your CI provider for an Artifactory access token, so no long-lived credential has to be stored anywhere.
Method 1: Generate a token from the JFrog Platform UI
-
Log in to the JFrog Platform as an administrator.
-
In the Administration module, go to User Management | Access Tokens.
-
Click + Generate Token.
-
Fill in the fields:
Field
|
Description
|
Token scope
|
Admin (token with admin permissions), User (permissions of a specific user), or Group (permissions of a group)
|
Description
|
A short description that identifies the purpose of the token
|
Expiration time
|
When the token expires. Pick one of the presets or set a custom value
|
Service
|
The services the token is allowed to access (Artifactory, Xray, and so on). Select All or clear the checkbox and pick specific services
|
Create Reference Token
|
Also returns a shorter Reference Token that can be used as a bearer token, as a password for basic authentication, or with the X-JFrog-Art-Api header
|
-
Click Generate.
-
Copy the token from the Generate Token window, which displays the username, scope, audience, expiration, token ID, the full token, and (if selected) the Reference Token. Use the copy icon next to a value to copy it, you can refer to the image below:

Important:
Tokens generated here are not stored in the JFrog Platform for security reasons. Copy the token before closing the window, because once the window is closed the token cannot be retrieved again.
Non-admin users
A non-admin user does not need an administrator to get a token. Any user can generate an Identity Token for themselves from Edit Profile in the user menu. Identity Tokens replace the deprecated API keys.
Note:
Please note that the "Can Update Profile" option must be enabled in the non-admin user's profile in order for the user to generate an Identity Token.
Reference Tokens
From Artifactory 7.38.4 you can choose between an extended token (the full JWT) and a Reference Token, which is a shorter, opaque alias for that JWT. Reference Tokens are convenient for clients that cannot handle a long JWT, and they can be used as a password with basic authentication:
curl -u <USERNAME>:<REFERENCE_TOKEN> "https://<JFROG_PLATFORM_URL>/artifactory/api/system/ping"
When using a Reference Token as a password, you must use the same username that the token was created for.
Method 2: Generate a token with REST API using a Bearer token
Use this method once you already have a valid token, for example to rotate tokens or to create narrowly scoped tokens from a script.
-
Store your existing token in an environment variable:
export TOKEN="<EXISTING_TOKEN>"
-
Create a new token with the Create Token API:
curl -H "Authorization: Bearer $TOKEN" \
-XPOST "http://<JFROG_PLATFORM_URL>/access/api/v1/tokens" \
-H "Content-type: application/json" \
-d '{
"description": "ci-build-agent",
"scope": "applied-permissions/admin",
"expires_in": 3600,
"include_reference_token": true
}'The commonly used request fields are:
Field
|
Description
|
scope
|
applied-permissions/admin, applied-permissions/user, applied-permissions/groups:<group1>,<group2>, or applied-permissions/roles:<project-key>:<role1>,<role2>
|
username
|
The user the token is issued for. Required for a user-scoped token
|
description
|
Free-text description used to identify the token later
|
expires_in
|
Validity period in seconds. 0 creates a non-expiring token (subject to the configured maximum expiry)
|
refreshable
|
When true, the response also contains a refresh_token
|
include_reference_token
|
When true, the response also contains a reference_token
|
Refreshable tokens
Refreshable tokens are not available in the UI. Add "refreshable": true to the Create Token payload, and the response will include a refresh_token that lets you obtain a new token with the same privileges without providing the original one. Refreshing uses the same endpoint as Create Token with grant_type=refresh_token. Only the instance that issued the token can refresh it. See Generate Refreshable Tokens for the full parameter list.
Method 3: Generate a token with REST API using basic authentication
You can create a token directly with your username and password. By default this is disabled for security reasons: calling the Create Token API with -u <user>:<password> fails with 401 Unauthorized until the feature is enabled.
{"errors":[{"code":"UNAUTHORIZED","message":"Unsupported authentication method Basic"}]}The setting is token.allow-basic-auth in the Access configuration. It is exposed in the UI as Enable Token Generation via API. Use whichever of the following options fits your installation, then create the token.
Option A: Enable it from the UI
-
In the Administration module, go to Security | General.
-
In the Basic Authentication section, select Enable Token Generation via API.
-
Click Save.
Option B: Enable it in the Access YAML file
This is the fully UI-free path. On the Artifactory server:
-
Go to $JFROG_HOME/artifactory/var/etc/access and copy the current configuration to an import file:
cd $JFROG_HOME/artifactory/var/etc/access
cp access.config.latest.yml access.config.import.yml
-
Edit access.config.import.yml and set allow-basic-auth to true under the token section, adding the section if it does not exist yet:
token:
allow-basic-auth: true # when enabled, allow basic authentication for the create token API
-
Restart Artifactory. On startup, Access imports access.config.import.yml, applies the change, and renames the file back to access.config.latest.yml.
For details, see Upload the Access YAML File and Supported Access Configurations.
Option C: Enable it with Helm
Add the value under access.accessConfig in your values.yaml, keeping the same indentation as the Access configuration file:
access:
accessConfig:
token:
allow-basic-auth: trueSee How to update the Access configuration file using Helm.
Create the token
Once the setting is applied, call the Create Token API with -u instead of a Bearer header:
curl -u <USERNAME>:<PASSWORD> \
-XPOST "http://<JFROG_PLATFORM_URL>/access/api/v1/tokens" \
-H "Content-type: application/json" \
-d '{
"description": "initial-automation-token",
"scope": "applied-permissions/admin",
"expires_in": 3600,
"include_reference_token": true
}'The response contains the access_token, and the reference_token if it was requested:
{
"token_id": "<TOKEN_ID>",
"access_token": "<ACCESS_TOKEN>",
"expires_in": 3600,
"scope": "applied-permissions/admin",
"token_type": "Bearer",
"reference_token": "<REFERENCE_TOKEN>",
"description": "initial-automation-token",
"username": "admin"
}
Related resources