ListPersonalAccessTokens
client.Users.Pats.List(ctx, params) (*PersonalAccessTokensPage[PersonalAccessToken], error)
POST/gitpod.v1.UserService/ListPersonalAccessTokens
Lists personal access tokens with optional filtering.
Use this method to:
- View all active tokens
- Audit token usage
- Manage token lifecycle
Examples
-
List user tokens:
Shows all tokens for specific users.
filter: userIds: ["f53d2330-3795-4c5d-a1f3-453121af9c60"] pagination: pageSize: 20
ListPersonalAccessTokens
package main
import (
"context"
"fmt"
"github.com/gitpod-io/gitpod-sdk-go"
"github.com/gitpod-io/gitpod-sdk-go/option"
)
func main() {
client := gitpod.NewClient(
option.WithBearerToken("My Bearer Token"),
)
page, err := client.Users.Pats.List(context.TODO(), gitpod.UserPatListParams{
Filter: gitpod.F(gitpod.UserPatListParamsFilter{
UserIDs: gitpod.F([]string{"f53d2330-3795-4c5d-a1f3-453121af9c60"}),
}),
Pagination: gitpod.F(gitpod.UserPatListParamsPagination{
PageSize: gitpod.F(int64(20)),
}),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", page)
}
{
"pagination": {
"nextToken": "nextToken"
},
"personalAccessTokens": [
{
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"createdAt": "2019-12-27T18:11:19.117Z",
"creator": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"principal": "PRINCIPAL_UNSPECIFIED"
},
"description": "description",
"expiresAt": "2019-12-27T18:11:19.117Z",
"lastUsed": "2019-12-27T18:11:19.117Z",
"readOnly": true,
"userId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
}
]
}Returns Examples
{
"pagination": {
"nextToken": "nextToken"
},
"personalAccessTokens": [
{
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"createdAt": "2019-12-27T18:11:19.117Z",
"creator": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"principal": "PRINCIPAL_UNSPECIFIED"
},
"description": "description",
"expiresAt": "2019-12-27T18:11:19.117Z",
"lastUsed": "2019-12-27T18:11:19.117Z",
"readOnly": true,
"userId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
}
]
}