개인 액세스 토큰 생성

개인 액세스 토큰 생성 (Create personal access token)

Docker Hub API에서 새 개인 액세스 토큰(personal access token)을 만드는 작업이에요. 권한 범위와 라벨을 지정하면 새 토큰이 생성돼요.

출처: 문서

본문

POST 요청으로 개인 액세스 토큰을 생성합니다. bearerAuth 인증이 필요해요.

요청 본문

createAccessTokenRequest 스키마예요. 예를 들면 이렇게 생겼어요.

{
  "scopes": [
    "repo:read"
  ],
  "token_label": "My read only token"
}

응답 201

생성된 토큰이 createAccessTokensResponse로 돌아와요. 이때 token 값에 실제 토큰 문자열이 담겨요.

{
  "client_id": "HUB",
  "created_at": "2021-07-20T12:00:00.000000Z",
  "creator_ip": "127.0.0.1",
  "creator_ua": "some user agent",
  "expires_at": "2021-10-28T18:30:19.520861Z",
  "generated_by": "manual",
  "is_active": true,
  "last_used": null,
  "scopes": [
    "repo:read"
  ],
  "token": "a7a5ef25-8889-43a0-8cc7-f2a94268e861",
  "token_label": "My read only token",
  "uuid": "b30bbf97-506c-4ecd-aabc-842f3cb484fb"
}

오류 응답

  • 400: 잘못된 요청 (bad request)
  • 401: 인증 실패 (unauthorized)

예시 요청

curl \
  --request POST \
  --header "Authorization: Bearer ***" \
  --header 'Content-Type: application/json' \
  --data-raw '{
  "scopes": [
    "repo:read"
  ],
  "token_label": "My read only token"
}' \
  'https://hub.docker.com/v2/access-tokens'

더 알아보기