0

When I try to create new token with GitLab API like this:

curl --request POST --header "PRIVATE-TOKEN: glpat-" --data "name=test-token-short-ttl" --data "scopes[]=read_repository" --data "expires_at=2025-08-06" --url "https://gitlab.example.ru/api/v4/user/personal_access_tokens"

I got the error

"error":"scopes does not have a valid value"}

But in documentation this scope is valid

1

1 Answer 1

0

That call will create a personal access token for your account, and to quote the documentation:

Creates a personal access token for your account. For security purposes, the token:

  • Is limited to the k8s_proxy scope. This scope grants permission to perform Kubernetes API calls using the agent for Kubernetes.

You can use the API with admin credetials to create an access for a given user with the read_repository scope - note the useage of the /users/:user_id API instead of the /user API:

curl --request POST \
     --header "PRIVATE-TOKEN: glpat-" \
     --data "name=test-token-short-ttl" \
     --data "scopes[]=read_repository" \
     --data "expires_at=2025-08-06" \
     --url "https://gitlab.example.ru/api/v4/users/42/personal_access_tokens"
# the user ID -------------------------------------^
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.