Unable to create project access tokens using the api

Summary

I am unable to create a project access token using the Gitlab API. I'm using this API. I am passing it my personal token for authentication which has all the scopes checked (api, read_user, read_api, read_repository, write_repository, read_registry, write_registry). But it returns me 400 Bad request - User does not have permission to create project access token. Also, I am the maintainer of this library.

Steps to reproduce

Make a curl request:

curl --request POST --header "PRIVATE-TOKEN: <private_token>" \
--header "Content-Type:application/json" \
--data '{ "name":"LIB_TOKEN", "scopes":["api"], "expires_at":"2022-01-31" }' \
"https://gitlab.com/api/v4/projects/<id>/access_tokens"

Example Project

What is the current bug behavior?

Returns {"message":"400 Bad request - User does not have permission to create project access token"}

What is the expected correct behavior?

Should return the correct payload that is mentioned in the doc.

Relevant logs and/or screenshots

Output of checks

Results of GitLab environment info

Expand for output related to GitLab environment info

(For installations with omnibus-gitlab package run and paste the output of:
`sudo gitlab-rake gitlab:env:info`)

(For installations from source run and paste the output of:
`sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)

Results of GitLab application Check

Expand for output related to the GitLab application check

(For installations with omnibus-gitlab package run and paste the output of: sudo gitlab-rake gitlab:check SANITIZE=true)

(For installations from source run and paste the output of: sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true)

(we will only investigate if the tests are passing)

Possible fixes

Edited Aug 02, 2025 by 🤖 GitLab Bot 🤖
Assignee Loading
Time tracking Loading