Create an authentication token
Deprecated
Run in API Explorer
Creates 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.
POST
/v2/users/login
curl \
--request POST 'https://hub.docker.com/v2/users/login' \
--header "Content-Type: application/json" \
--data '{"username":"myusername","password":"p@ssw0rd"}'
Request examples
{
"username": "myusername",
"password": "p@ssw0rd"
}
Response examples (200)
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
}
Response examples (401)
{
"detail": "Incorrect authentication credentials",
"login_2fa_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
}