According to the documentation, it should be possible to access GitLab repos with project access tokens:
The username is set to project_{project_id}_bot, such as project_123_bot.
Never mind that that's a lie -- the actual user is called project_4194_bot1
in my case; apparently they increment a number for subsequent tokens.
Either way -- and I have tried both with and without the trailing 1
-- I would expect
git clone "https://project_4194_bot1:$PROJECT_TOKEN@my.gitlab.host/my-group/my-project.git"
to succeed, same as with my.username:$PERSONAL_TOKEN
(which works perfectly). However, I get
remote: HTTP Basic: Access denied
fatal: Authentication failed for '<snip>'
What may be going on here? How can I access GitLab repositories using project access tokens?
It's not as if we'd get that far, but FWIW, the token seems to have sufficient permissions:
It seems that using the project name as username works. In your case replacing project_4194_bot1
with my-project
should work:
git clone "https://my-project:$PROJECT_TOKEN@my.gitlab.host/my-group/my-project.git"
EDIT: One can actually use any non-blank value as a username (see docs), as others correctly pointed out.