Create access token
/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.
Connection and access
API connection and authentication guidance
https://hub.docker.com
—
Docker HUB API
No HTTP authentication requirement is declared for this operation. Transport access controls can still apply.
Parameters
No parameters are declared.
Request and responses
Request
application/json
Type:
object
identifier
· required
Type:
string
All schema constraints and annotations
{
"description": "The identifier of the account to create an access token for. If using a password or personal access token,\nthis must be a username. If using an organization access token, this must be an organization name.\n",
"example": "myusername",
"type": "string"
}secret
· required
Type:
string
All schema constraints and annotations
{
"description": "The secret of the account to create an access token for. This can be a password, personal access token, or\norganization access token.\n",
"example": "dckr_pat_124509ugsdjga93",
"type": "string"
}All schema constraints and annotations
{
"description": "Request to create access token",
"examples": [
{
"identifier": "myusername",
"secret": "dckr_pat_124509ugsdjga93"
}
],
"properties": {
"identifier": {
"description": "The identifier of the account to create an access token for. If using a password or personal access token,\nthis must be a username. If using an organization access token, this must be an organization name.\n",
"example": "myusername",
"type": "string"
},
"secret": {
"description": "The secret of the account to create an access token for. This can be a password, personal access token, or\norganization access token.\n",
"example": "dckr_pat_124509ugsdjga93",
"type": "string"
}
},
"required": [
"identifier",
"secret"
],
"type": "object"
}Schema example
{
"identifier": "myusername",
"secret": "dckr_pat_124509ugsdjga93"
}Response
200
application/json
Schema:
AuthCreateTokenResponse
Schema example
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
}Response
401
application/json
Schema:
error
error
{
"errinfo": null,
"message": "unauthorized"
}Referenced schemas
#/components/schemas/AuthCreateTokenResponse
Complete operation contract
{
"description": "Creates and returns a short-lived access token in JWT format for use as a bearer when calling Docker APIs.\n\nIf successful, the access token returned should be used in the HTTP Authorization header like \n`Authorization: Bearer {access_token}`.\n\n_**If your organization has SSO enforced, you must use a personal access token (PAT) instead of a password.**_\n",
"operationId": "AuthCreateAccessToken",
"requestBody": {
"content": {
"application/json": {
"schema": {
"description": "Request to create access token",
"examples": [
{
"identifier": "myusername",
"secret": "dckr_pat_124509ugsdjga93"
}
],
"properties": {
"identifier": {
"description": "The identifier of the account to create an access token for. If using a password or personal access token,\nthis must be a username. If using an organization access token, this must be an organization name.\n",
"example": "myusername",
"type": "string"
},
"secret": {
"description": "The secret of the account to create an access token for. This can be a password, personal access token, or\norganization access token.\n",
"example": "dckr_pat_124509ugsdjga93",
"type": "string"
}
},
"required": [
"identifier",
"secret"
],
"type": "object"
}
}
}
},
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/AuthCreateTokenResponse"
}
}
},
"description": "Token created"
},
"401": {
"$ref": "#/components/responses/unauthorized",
"description": "Authentication failed"
}
},
"security": [],
"summary": "Create access token",
"tags": [
"authentication-api"
]
}