Skip to content

tokens

Accessed as client.admin.users.tokens; the async client mirrors it.

AdminUsersTokens

The admin.users.tokens namespace.

create

create(
    username: str, *, name: str, repositories: list[RepoTargetOption] | None = None, scopes: list[str] | None = None
) -> AccessToken

Create an access token for the specified user.

Parameters:

Name Type Description Default
username str

username of user

required
name str
required
repositories list[RepoTargetOption] | None

If provided and not-empty, creates an access token with access only to specified repositories.

None
scopes list[str] | None
None

Returns:

Type Description
AccessToken

AccessToken represents an API access token.

Raises:

Type Description
BadRequestError
  1. APIError is error format response.
ForbiddenError
  1. APIForbiddenError is a forbidden error response.
NotFoundError
  1. APINotFound is a not found error response.

Operation ID: adminCreateUserAccessToken

delete

delete(username: str, token: str) -> None

Delete an access token for the specified user.

Parameters:

Name Type Description Default
username str

username of user

required
token str

token to be deleted, identified by ID and if not available by name

required

Returns:

Type Description
None

No content.

Raises:

Type Description
ForbiddenError
  1. APIForbiddenError is a forbidden error response.
NotFoundError
  1. APINotFound is a not found error response.
UnprocessableEntityError
  1. APIError is error format response.

Operation ID: adminDeleteUserAccessToken

list

list(username: str, *, page: int | None = None, limit: int | None = None) -> Paginated[AccessToken]

List the specified user's access tokens.

Parameters:

Name Type Description Default
username str

username of user

required
page int | None

1-based page to start iteration at.

None
limit int | None

Page size; the instance caps it server-side.

None

Returns:

Type Description
Paginated[AccessToken]

AccessTokenList.

Raises:

Type Description
ForbiddenError
  1. APIForbiddenError is a forbidden error response.
NotFoundError
  1. APINotFound is a not found error response.

Operation ID: adminListUserAccessTokens

AsyncAdminUsersTokens

The admin.users.tokens namespace.

create

create(
    username: str, *, name: str, repositories: list[RepoTargetOption] | None = None, scopes: list[str] | None = None
) -> AccessToken

Create an access token for the specified user.

Parameters:

Name Type Description Default
username str

username of user

required
name str
required
repositories list[RepoTargetOption] | None

If provided and not-empty, creates an access token with access only to specified repositories.

None
scopes list[str] | None
None

Returns:

Type Description
AccessToken

AccessToken represents an API access token.

Raises:

Type Description
BadRequestError
  1. APIError is error format response.
ForbiddenError
  1. APIForbiddenError is a forbidden error response.
NotFoundError
  1. APINotFound is a not found error response.

Operation ID: adminCreateUserAccessToken

delete

delete(username: str, token: str) -> None

Delete an access token for the specified user.

Parameters:

Name Type Description Default
username str

username of user

required
token str

token to be deleted, identified by ID and if not available by name

required

Returns:

Type Description
None

No content.

Raises:

Type Description
ForbiddenError
  1. APIForbiddenError is a forbidden error response.
NotFoundError
  1. APINotFound is a not found error response.
UnprocessableEntityError
  1. APIError is error format response.

Operation ID: adminDeleteUserAccessToken

list

list(username: str, *, page: int | None = None, limit: int | None = None) -> AsyncPaginated[AccessToken]

List the specified user's access tokens.

Parameters:

Name Type Description Default
username str

username of user

required
page int | None

1-based page to start iteration at.

None
limit int | None

Page size; the instance caps it server-side.

None

Returns:

Type Description
AsyncPaginated[AccessToken]

AccessTokenList.

Raises:

Type Description
ForbiddenError
  1. APIForbiddenError is a forbidden error response.
NotFoundError
  1. APINotFound is a not found error response.

Operation ID: adminListUserAccessTokens