curl 如何使用命令行从私有Bitbucket存储库下载单个原始文件?

g9icjywg  于 2022-11-13  发布在  其他
关注(0)|答案(1)|浏览(238)

我想从私人仓库下载一个文件,而不是克隆整个文件。
我能找到的所有结果都表明了同样的一点:在Bitbucket中创建一个应用程序密码,然后使用该密码沿着您的用户名。我试过了:

curl -u my_username:app_password https://bitbucket.org/my_username/the_repo/raw/commit_sha/the_file

我知道这个URL至少是合理的,因为如果我登录到Bitbucket,我可以在浏览器中查看它。
但运行curl命令失败,并显示错误:

Bitbucket Cloud recently stopped supporting account passwords for API authentication.
See our community post for more details: https://atlassian.community/t5/x/x/ba-p/1948231
App passwords are recommended for most use cases and can be created in your Personal settings:
https://bitbucket.org/account/settings/app-passwords/
For more details on API authentication methods see our documentation:
https://developer.atlassian.com/cloud/bitbucket/rest/intro/#authentication

提到的第二个链接有一个关于应用程序密码的部分,并没有说太多关于如何实际使用它们。
使用git clone的应用程序密码工作正常,但我不知道如何让它与curl一起工作。

bq8i3lrv

bq8i3lrv1#

这对我很有效:

curl -u <user>:<app_password> -L -O https://api.bitbucket.org/2.0/repositories/<org>/<repo>/src/<branch>/<file>

位桶REST API文档

相关问题