2FA(2단계 인증) 로그인

2FA(2단계 인증) 로그인

사용자에게 2단계 인증(2FA)이 활성화되어 있을 때 /v2/users/login 호출 다음에 수행하는 두 번째 호출이에요. JWT 형식의 bearer 토큰을 만들어 반환하고, 이 토큰으로 Docker Hub API를 인증해요.

출처: 문서

본문

POST /v2/users/2fa-login

2FA(2단계 인증) 로그인 작업이에요. 사용자에게 2단계 인증(2FA)이 활성화되어 있을 때 /v2/users/login 호출 다음에 수행하는 두 번째 호출이에요. JWT 형식의 bearer 토큰을 만들어 반환하고, 이 토큰으로 Docker Hub API를 인증해요.

요청 예시

실행 전에 자리 표시자를 바꾸고 필요 자격 증명이나 요청 바디를 채워야 해요.

curl \
  --request POST \
  --header 'Accept: application/json' \
  --header 'Content-Type: application/json' \
  --data-raw '{
  "code": "123456",
  "login_2fa_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
}' \
  'https://hub.docker.com/v2/users/2fa-login'

요청과 응답

응답 200 Authentication successful

Schema:

{
  "$ref": "#/components/schemas/PostUsersLoginSuccessResponse"
}

Schema example:

{
  "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c"
}

응답 401 Authentication failed

Schema:

{
  "$ref": "#/components/schemas/PostUsers2FALoginErrorResponse"
}

Schema example:

{
  "detail": "Incorrect authentication credentials"
}

전체 작업 계약

{
  "description": "When a user has two-factor authentication (2FA) enabled, this is the second call to perform after `/v2/users/login` call.\n\nCreates 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\nMost Docker Hub APIs require this token either to consume or to get detailed information. For example, to list images in a private repository.\n",
  "operationId": "PostUsers2FALogin",
  "requestBody": {
    "content": {
      "application/json": {
        "schema": {
          "$ref": "#/components/schemas/Users2FALoginRequest"
        }
      }
    },
    "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/PostUsers2FALoginErrorResponse"
          }
        }
      },
      "description": "Authentication failed"
    }
  },
  "security": [],
  "summary": "Second factor authentication",
  "tags": [
    "authentication-api"
  ]
}

참조된 스키마

더 알아보기