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:[email protected]/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:
Under your GitHub user profile (not the repository profile), click the “Settings” link. Scroll down and click the “Developer Settings” link. Click the GitHub “Personal access tokens” link. Click the “Generate new token” link and provide your password again if required.
Project access tokens are similar to passwords, except you can limit access to resources, select a limited role, and provide an expiry date. Use a project access token to authenticate: With the GitLab API. With Git, when using HTTP Basic Authentication, use: Any non-blank value as a username.
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:[email protected]/my-group/my-project.git"
EDIT: One can actually use any non-blank value as a username (see docs), as others correctly pointed out.
From the GitLab documentation:
With Git, when using HTTP Basic Authentication, use:
- Any non-blank value as a username.
- The project access token as the password.
In previous GitLab versions, it would have been necessary to use project_4194_bot1
as the username. However, the current version lets you use any username you wish:
git clone "https://anything:[email protected]/my-group/my-project.git"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With