InfoGrab Docs

사용자 토큰 API

요약

이 API를 사용하여 개인 액세스 토큰과 가장 토큰을 다룹니다. 지정된 사용자를 위한 개인 액세스 토큰을 생성합니다. 토큰 값은 응답에 포함되지만 나중에 조회할 수 없습니다. 계정에 대한 개인 액세스 토큰을 생성합니다. 지정된 사용자의 모든 가장 토큰을 나열합니다.

이 API를 사용하여 개인 액세스 토큰과 가장 토큰을 다룹니다. 자세한 내용은 개인 액세스 토큰가장 토큰을 참조하세요.

사용자를 위한 개인 액세스 토큰 생성#

히스토리
  • expires_at 속성 기본값이 GitLab 16.0에서 도입되었습니다.

지정된 사용자를 위한 개인 액세스 토큰을 생성합니다.

토큰 값은 응답에 포함되지만 나중에 조회할 수 없습니다.

사전 요구 사항:

  • 인스턴스에 대한 관리자 권한이 있어야 합니다.
POST /users/:user_id/personal_access_tokens

지원되는 속성:

속성 타입 필수 여부 설명
user_id integer yes 사용자 계정의 ID.
name string yes 개인 액세스 토큰의 이름.
description string no 개인 액세스 토큰의 설명. 최대: 255자.
expires_at date no ISO 형식의 액세스 토큰 만료 날짜 (YYYY-MM-DD). 정의되지 않은 경우 날짜가 최대 허용 수명 제한으로 설정됩니다.
scopes array yes 승인된 범위의 배열. 가능한 값 목록은 개인 액세스 토큰 범위를 참조하세요.

요청 예시:

curl --request POST \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --data "name=mytoken" --data "expires_at=2017-04-04" \
  --data "scopes[]=api" \
  --url "https://gitlab.example.com/api/v4/users/42/personal_access_tokens"

응답 예시:

{
    "id": 3,
    "name": "mytoken",
    "revoked": false,
    "created_at": "2020-10-14T11:58:53.526Z",
    "description": "Test Token description",
    "scopes": [
        "api"
    ],
    "user_id": 42,
    "active": true,
    "expires_at": "2020-12-31",
    "token": "<your_new_access_token>"
}

개인 액세스 토큰 생성#

히스토리
  • GitLab 16.5에서 도입되었습니다.

계정에 대한 개인 액세스 토큰을 생성합니다. 보안을 위해 토큰은:

토큰 값은 응답에 포함되지만 나중에 조회할 수 없습니다.

사전 요구 사항:

  • 인증되어 있어야 합니다.
POST /user/personal_access_tokens

지원되는 속성:

속성 타입 필수 여부 설명
name string yes 개인 액세스 토큰의 이름.
description string no 개인 액세스 토큰의 설명. 최대: 255자.
scopes array yes 승인된 범위의 배열. k8s_proxyself_rotate만 허용됩니다.
expires_at date no ISO 형식의 액세스 토큰 만료 날짜 (YYYY-MM-DD). 정의되지 않은 경우 날짜가 최대 허용 수명 제한으로 설정됩니다.

요청 예시:

curl --request POST \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --data "name=mytoken" --data "scopes[]=k8s_proxy" \
  --url "https://gitlab.example.com/api/v4/user/personal_access_tokens"

응답 예시:

{
    "id": 3,
    "name": "mytoken",
    "revoked": false,
    "created_at": "2020-10-14T11:58:53.526Z",
    "description": "Test Token description",
    "scopes": [
        "k8s_proxy"
    ],
    "user_id": 42,
    "active": true,
    "expires_at": "2020-10-15",
    "token": "<your_new_access_token>"
}

사용자의 모든 가장 토큰 목록 조회#

지정된 사용자의 모든 가장 토큰을 나열합니다.

pageper_page 페이지네이션 파라미터를 사용하여 결과를 필터링합니다.

사전 요구 사항:

  • 인스턴스에 대한 관리자 권한이 있어야 합니다.
GET /users/:user_id/impersonation_tokens

지원되는 속성:

속성 타입 필수 여부 설명
user_id integer yes 사용자 계정의 ID
state string no 상태에 따라 토큰 필터링. 가능한 값: all, active 또는 inactive.

요청 예시:

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/users/42/impersonation_tokens"

응답 예시:

[
   {
      "active" : true,
      "user_id" : 2,
      "scopes" : [
         "api"
      ],
      "revoked" : false,
      "name" : "mytoken",
      "description": "Test Token description",
      "id" : 2,
      "created_at" : "2017-03-17T17:18:09.283Z",
      "impersonation" : true,
      "expires_at" : "2017-04-04",
      "last_used_at": "2017-03-24T09:44:21.722Z"
   },
   {
      "active" : false,
      "user_id" : 2,
      "scopes" : [
         "read_user"
      ],
      "revoked" : true,
      "name" : "mytoken2",
      "description": "Test Token description",
      "created_at" : "2017-03-17T17:19:28.697Z",
      "id" : 3,
      "impersonation" : true,
      "expires_at" : "2017-04-14",
      "last_used_at": "2017-03-24T09:44:21.722Z"
   }
]

사용자의 가장 토큰 조회#

지정된 사용자의 가장 토큰을 조회합니다.

사전 요구 사항:

  • 인스턴스에 대한 관리자 권한이 있어야 합니다.
GET /users/:user_id/impersonation_tokens/:impersonation_token_id

지원되는 속성:

속성 타입 필수 여부 설명
user_id integer yes 사용자 계정의 ID
impersonation_token_id integer yes 가장 토큰의 ID

요청 예시:

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/users/42/impersonation_tokens/2"

응답 예시:

{
   "active" : true,
   "user_id" : 2,
   "scopes" : [
      "api"
   ],
   "revoked" : false,
   "name" : "mytoken",
   "description": "Test Token description",
   "id" : 2,
   "created_at" : "2017-03-17T17:18:09.283Z",
   "impersonation" : true,
   "expires_at" : "2017-04-04"
}

가장 토큰 생성#

지정된 사용자를 위한 가장 토큰을 생성합니다. 이 토큰은 사용자를 대신하여 작업하는 데 사용되며 API 호출과 Git 읽기 및 쓰기 작업을 수행할 수 있습니다. 이 토큰은 연결된 사용자의 프로필 설정 페이지에 표시되지 않습니다.

토큰 값은 응답에 포함되지만 나중에 조회할 수 없습니다.

사전 요구 사항:

  • 인스턴스에 대한 관리자 권한이 있어야 합니다.
POST /users/:user_id/impersonation_tokens

지원되는 속성:

속성 타입 필수 여부 설명
user_id integer yes 사용자 계정의 ID
name string yes 가장 토큰의 이름
description string no 가장 토큰의 설명
expires_at date yes ISO 형식의 가장 토큰 만료 날짜 (YYYY-MM-DD). 정의되지 않은 경우 날짜가 최대 허용 수명 제한으로 설정됩니다.
scopes array yes 승인된 범위의 배열. 가능한 값 목록은 개인 액세스 토큰 범위를 참조하세요.

요청 예시:

curl --request POST \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --data "name=mytoken" --data "expires_at=2017-04-04" \
  --data "scopes[]=api" \
  --url "https://gitlab.example.com/api/v4/users/42/impersonation_tokens"

응답 예시:

{
   "id" : 2,
   "revoked" : false,
   "user_id" : 2,
   "scopes" : [
      "api"
   ],
   "token" : "<impersonation_token>",
   "active" : true,
   "impersonation" : true,
   "name" : "mytoken",
   "description": "Test Token description",
   "created_at" : "2017-03-17T17:18:09.283Z",
   "expires_at" : "2017-04-04"
}

가장 토큰 취소#

지정된 사용자의 가장 토큰을 취소합니다.

사전 요구 사항:

  • 인스턴스에 대한 관리자 권한이 있어야 합니다.
DELETE /users/:user_id/impersonation_tokens/:impersonation_token_id

지원되는 속성:

속성 타입 필수 여부 설명
user_id integer yes 사용자 계정의 ID
impersonation_token_id integer yes 가장 토큰의 ID

요청 예시:

curl --request DELETE \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/users/42/impersonation_tokens/1"

사용자 토큰 API

Tier: Free, Premium, Ultimate
Offering: GitLab Self-Managed, GitLab Dedicated
원문 보기
요약

이 API를 사용하여 개인 액세스 토큰과 가장 토큰을 다룹니다. 지정된 사용자를 위한 개인 액세스 토큰을 생성합니다. 토큰 값은 응답에 포함되지만 나중에 조회할 수 없습니다. 계정에 대한 개인 액세스 토큰을 생성합니다. 지정된 사용자의 모든 가장 토큰을 나열합니다.

이 API를 사용하여 개인 액세스 토큰과 가장 토큰을 다룹니다. 자세한 내용은 개인 액세스 토큰가장 토큰을 참조하세요.

사용자를 위한 개인 액세스 토큰 생성#

히스토리
  • expires_at 속성 기본값이 GitLab 16.0에서 도입되었습니다.

지정된 사용자를 위한 개인 액세스 토큰을 생성합니다.

토큰 값은 응답에 포함되지만 나중에 조회할 수 없습니다.

사전 요구 사항:

  • 인스턴스에 대한 관리자 권한이 있어야 합니다.
POST /users/:user_id/personal_access_tokens

지원되는 속성:

속성 타입 필수 여부 설명
user_id integer yes 사용자 계정의 ID.
name string yes 개인 액세스 토큰의 이름.
description string no 개인 액세스 토큰의 설명. 최대: 255자.
expires_at date no ISO 형식의 액세스 토큰 만료 날짜 (YYYY-MM-DD). 정의되지 않은 경우 날짜가 최대 허용 수명 제한으로 설정됩니다.
scopes array yes 승인된 범위의 배열. 가능한 값 목록은 개인 액세스 토큰 범위를 참조하세요.

요청 예시:

curl --request POST \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --data "name=mytoken" --data "expires_at=2017-04-04" \
  --data "scopes[]=api" \
  --url "https://gitlab.example.com/api/v4/users/42/personal_access_tokens"

응답 예시:

{
    "id": 3,
    "name": "mytoken",
    "revoked": false,
    "created_at": "2020-10-14T11:58:53.526Z",
    "description": "Test Token description",
    "scopes": [
        "api"
    ],
    "user_id": 42,
    "active": true,
    "expires_at": "2020-12-31",
    "token": "<your_new_access_token>"
}

개인 액세스 토큰 생성#

히스토리
  • GitLab 16.5에서 도입되었습니다.

계정에 대한 개인 액세스 토큰을 생성합니다. 보안을 위해 토큰은:

토큰 값은 응답에 포함되지만 나중에 조회할 수 없습니다.

사전 요구 사항:

  • 인증되어 있어야 합니다.
POST /user/personal_access_tokens

지원되는 속성:

속성 타입 필수 여부 설명
name string yes 개인 액세스 토큰의 이름.
description string no 개인 액세스 토큰의 설명. 최대: 255자.
scopes array yes 승인된 범위의 배열. k8s_proxyself_rotate만 허용됩니다.
expires_at date no ISO 형식의 액세스 토큰 만료 날짜 (YYYY-MM-DD). 정의되지 않은 경우 날짜가 최대 허용 수명 제한으로 설정됩니다.

요청 예시:

curl --request POST \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --data "name=mytoken" --data "scopes[]=k8s_proxy" \
  --url "https://gitlab.example.com/api/v4/user/personal_access_tokens"

응답 예시:

{
    "id": 3,
    "name": "mytoken",
    "revoked": false,
    "created_at": "2020-10-14T11:58:53.526Z",
    "description": "Test Token description",
    "scopes": [
        "k8s_proxy"
    ],
    "user_id": 42,
    "active": true,
    "expires_at": "2020-10-15",
    "token": "<your_new_access_token>"
}

사용자의 모든 가장 토큰 목록 조회#

지정된 사용자의 모든 가장 토큰을 나열합니다.

pageper_page 페이지네이션 파라미터를 사용하여 결과를 필터링합니다.

사전 요구 사항:

  • 인스턴스에 대한 관리자 권한이 있어야 합니다.
GET /users/:user_id/impersonation_tokens

지원되는 속성:

속성 타입 필수 여부 설명
user_id integer yes 사용자 계정의 ID
state string no 상태에 따라 토큰 필터링. 가능한 값: all, active 또는 inactive.

요청 예시:

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/users/42/impersonation_tokens"

응답 예시:

[
   {
      "active" : true,
      "user_id" : 2,
      "scopes" : [
         "api"
      ],
      "revoked" : false,
      "name" : "mytoken",
      "description": "Test Token description",
      "id" : 2,
      "created_at" : "2017-03-17T17:18:09.283Z",
      "impersonation" : true,
      "expires_at" : "2017-04-04",
      "last_used_at": "2017-03-24T09:44:21.722Z"
   },
   {
      "active" : false,
      "user_id" : 2,
      "scopes" : [
         "read_user"
      ],
      "revoked" : true,
      "name" : "mytoken2",
      "description": "Test Token description",
      "created_at" : "2017-03-17T17:19:28.697Z",
      "id" : 3,
      "impersonation" : true,
      "expires_at" : "2017-04-14",
      "last_used_at": "2017-03-24T09:44:21.722Z"
   }
]

사용자의 가장 토큰 조회#

지정된 사용자의 가장 토큰을 조회합니다.

사전 요구 사항:

  • 인스턴스에 대한 관리자 권한이 있어야 합니다.
GET /users/:user_id/impersonation_tokens/:impersonation_token_id

지원되는 속성:

속성 타입 필수 여부 설명
user_id integer yes 사용자 계정의 ID
impersonation_token_id integer yes 가장 토큰의 ID

요청 예시:

curl --request GET \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/users/42/impersonation_tokens/2"

응답 예시:

{
   "active" : true,
   "user_id" : 2,
   "scopes" : [
      "api"
   ],
   "revoked" : false,
   "name" : "mytoken",
   "description": "Test Token description",
   "id" : 2,
   "created_at" : "2017-03-17T17:18:09.283Z",
   "impersonation" : true,
   "expires_at" : "2017-04-04"
}

가장 토큰 생성#

지정된 사용자를 위한 가장 토큰을 생성합니다. 이 토큰은 사용자를 대신하여 작업하는 데 사용되며 API 호출과 Git 읽기 및 쓰기 작업을 수행할 수 있습니다. 이 토큰은 연결된 사용자의 프로필 설정 페이지에 표시되지 않습니다.

토큰 값은 응답에 포함되지만 나중에 조회할 수 없습니다.

사전 요구 사항:

  • 인스턴스에 대한 관리자 권한이 있어야 합니다.
POST /users/:user_id/impersonation_tokens

지원되는 속성:

속성 타입 필수 여부 설명
user_id integer yes 사용자 계정의 ID
name string yes 가장 토큰의 이름
description string no 가장 토큰의 설명
expires_at date yes ISO 형식의 가장 토큰 만료 날짜 (YYYY-MM-DD). 정의되지 않은 경우 날짜가 최대 허용 수명 제한으로 설정됩니다.
scopes array yes 승인된 범위의 배열. 가능한 값 목록은 개인 액세스 토큰 범위를 참조하세요.

요청 예시:

curl --request POST \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --data "name=mytoken" --data "expires_at=2017-04-04" \
  --data "scopes[]=api" \
  --url "https://gitlab.example.com/api/v4/users/42/impersonation_tokens"

응답 예시:

{
   "id" : 2,
   "revoked" : false,
   "user_id" : 2,
   "scopes" : [
      "api"
   ],
   "token" : "<impersonation_token>",
   "active" : true,
   "impersonation" : true,
   "name" : "mytoken",
   "description": "Test Token description",
   "created_at" : "2017-03-17T17:18:09.283Z",
   "expires_at" : "2017-04-04"
}

가장 토큰 취소#

지정된 사용자의 가장 토큰을 취소합니다.

사전 요구 사항:

  • 인스턴스에 대한 관리자 권한이 있어야 합니다.
DELETE /users/:user_id/impersonation_tokens/:impersonation_token_id

지원되는 속성:

속성 타입 필수 여부 설명
user_id integer yes 사용자 계정의 ID
impersonation_token_id integer yes 가장 토큰의 ID

요청 예시:

curl --request DELETE \
  --header "PRIVATE-TOKEN: <your_access_token>" \
  --url "https://gitlab.example.com/api/v4/users/42/impersonation_tokens/1"