使用项目访问令牌克隆私有gitlab存储库

问题描述 投票:0回答:2

我有一个托管在 gitlab.com 上的私有存储库。我创建了一个具有

read_repository
范围的项目访问令牌。目的是任何拥有项目访问令牌的用户都可以克隆存储库。

我发出:

git clone https://[email protected]/user/repo.git

当提示输入密码时,我输入项目访问令牌,但被告知:

Cloning into 'repo'...
Password for 'https://[email protected]': 
remote: You are not allowed to download code from this project.
fatal: unable to access 'https://gitlab.com/user/repo.git/': The requested URL returned error: 403

除了

read_repository
之外,我还尝试创建许多具有多个范围的附加项目访问令牌,但得到了相同的错误。我还尝试直接在克隆中使用项目访问令牌进行克隆:

git clone https://xyz:[email protected]/user/repo.git

但得到同样的错误。

澄清

我创建的所有项目访问令牌的到期日期都设置为从现在起一个月。据我了解,

xyz
字符串是无关紧要的,因为它是用户名的占位符。从 gitlab 文档来看,这似乎可以是任何非空字符串。

git gitlab access-token
2个回答
0
投票

xyz 代表什么? 您是存储库的所有者/您有权限吗?

--- 您真正想要做的是在实际令牌之前添加 oauth2 协议

 git clone https://oauth2:[email protected]/user/repo.git

如果没有帮助,请尝试使用此令牌执行 REST API 以确保其有效。

尝试参考这篇文章进行进一步调查。


0
投票

就我而言,问题是我们无法在私人存储库中使用“Guest”代币,即使权限为 403。使用“Reporter”或任何其他作品

© www.soinside.com 2019 - 2024. All rights reserved.