ARTIFACTORY: Resolution for Missing reference_token in API Token Generation Calls for JFrog Artifactory

Products
Frog_Artifactory
Content Type
Use_Case
AuthorFullName__c
Zhang Hailang
articleNumber
000006655
FirstPublishedDate
2025-10-16T07:04:19Z
lastModifiedDate
2025-10-16

ARTIFACTORY: Resolution for Missing reference_token in API Token Generation Calls for JFrog Artifactory

Introduction 

When attempting to generate a new access token using the Artifactory REST API endpoint (/access/api/v1/tokens), the response JSON does not include the reference_token field, even when the request payload explicitly sets "include_reference_token": true.
curl -H "Authorization: Bearer <your_base64_token>" \
-XPOST "http://127.0.0.1:8082/access/api/v1/tokens" \
-d '{"scope": "applied-permissions/user", "include_reference_token": true}'

# Response lacks the 'reference_token' field:
{
  "token_id" : "7c2b6dd0-5afc-4f8c-acb3-adbddce869ac",
  "access_token" : "eyJ2ZXIiOiIy...<very_long_JWT>",
  "expires_in" : 31536000,
  "scope" : "applied-permissions/user",
  "token_type" : "Bearer",
  "username" : "admin"
}


Root Cause

The Artifactory access service expects the request to have the Content-Type: application/json header to properly parse the JSON payload in the request body (-d flag). If this header is missing, the service may not process the optional parameters in the payload correctly, causing it to ignore the "include_reference_token": true instruction and default to not generating a reference token.



Resolution

The solution is to ensure all POST requests to the Artifactory API that contain a JSON body must include the Content-Type: application/json header.

Corrected Command:
curl -H "Content-Type: application/json" \
-H "Authorization: Bearer cm[...]DF2" \
-XPOST "http://127.0.0.1:8082/access/api/v1/tokens" \
-d '{"scope": "applied-permissions/user", "include_reference_token": true}'

Expected Successful Response:
The response will now correctly include the reference_token field
{
  "token_id" : "d794fb14-2983-4553-b634-9a47a4af14d3",
  "access_token" : "eyJ2ZXIiOiIy...<very_long_JWT>",
  "expires_in" : 31536000,
  "scope" : "applied-permissions/user",
  "token_type" : "Bearer",
  "reference_token" : "cmVmdGtuOjAxOjE3ODc3MzQ4MjQ6cWZqbmhRcGpiaGI5QmNpcUhzWkNjWkNIS3Y1",
  "username" : "admin"
}