Create access token Run in API Explorer

POST /v2/auth/token

Creates and returns a short-lived access token in JWT format for use as a bearer when calling Docker APIs.

If successful, the access token returned should be used in the HTTP Authorization header like Authorization: Bearer {access_token}.

If your organization has SSO enforced, you must use a personal access token (PAT) instead of a password.

application/json

Body

  • identifier string Required

    The identifier of the account to create an access token for. If using a password or personal access token, this must be a username. If using an organization access token, this must be an organization name.

  • secret string Required

    The secret of the account to create an access token for. This can be a password, personal access token, or organization access token.

Responses

  • 200 application/json

    Token created

    Hide response attribute Show response attribute object
    • access_token string

      The created access token. This expires in 10 minutes.

  • 401 application/json

    Authentication failed

    Hide response attributes Show response attributes object
    • errinfo object
    • detail string
    • message string
POST /v2/auth/token
curl \
 --request POST 'https://hub.docker.com/v2/auth/token' \
 --header "Content-Type: application/json" \
 --data '{"identifier":"myusername","secret":"dckr_pat_124509ugsdjga93"}'
Request examples
{
  "identifier": "myusername",
  "secret": "dckr_pat_124509ugsdjga93"
}
Response examples (200)
{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
}
Response examples (401)
{
  "errinfo": {},
  "detail": "string",
  "message": "string"
}