Create an authentication token
/v2/users/login
DeprecatedCreates and returns a bearer token in JWT format that you can use to authenticate with Docker Hub APIs.
The returned token is used in the HTTP Authorization header like Authorization: Bearer {TOKEN}.
As of September 16, 2024, this route requires a personal access token (PAT) instead of a password if your organization has SSO enforced.
Deprecated: Use Create access token instead.
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
Schema:
UsersLoginRequest
Schema example
{
"password": "p@ssw0rd",
"username": "myusername"
}Response
200
application/json
Schema:
PostUsersLoginSuccessResponse
Schema example
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
}Response
401
application/json
Schema:
PostUsersLoginErrorResponse
Schema example
{
"detail": "Incorrect authentication credentials"
}Referenced schemas
#/components/schemas/PostUsersLoginErrorResponse
#/components/schemas/PostUsersLoginSuccessResponse
#/components/schemas/UsersLoginRequest
Complete operation contract
{
"deprecated": true,
"description": "Creates and returns a bearer token in JWT format that you can use to authenticate with Docker Hub APIs.\n\nThe returned token is used in the HTTP Authorization header like `Authorization: Bearer {TOKEN}`.\n\n_**As of September 16, 2024, this route requires a personal access token (PAT) instead of a password if your organization has SSO enforced.**_\n\n\n Deprecated: Use [Create access token](#tag/authentication-api/operation/AuthCreateAccessToken) instead.\n\n",
"operationId": "PostUsersLogin",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/UsersLoginRequest"
}
}
},
"description": "Login details.",
"required": true
},
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PostUsersLoginSuccessResponse"
}
}
},
"description": "Authentication successful"
},
"401": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PostUsersLoginErrorResponse"
}
}
},
"description": "Authentication failed or second factor required"
}
},
"security": [],
"summary": "Create an authentication token",
"tags": [
"authentication-api"
]
}