我已经创建了一个应用程序的密码作为解释这里
但是现在,如何使用此应用密码访问存储库?
什么是网址?
有人可以指导我到一个显示示例的页面吗?
以下是github的代码.我如何为bitbucket做到这一点?
var githubToken = "[token]";
var url = "https://github.com/[username]/[repository]/archive/[sha1|tag].zip";
var path = @"[local path]";
using (var client = new System.Net.Http.HttpClient())
{
var credentials = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0}:", githubToken);
credentials = Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(credentials));
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Basic", credentials);
var contents = client.GetByteArrayAsync(url).Result;
System.IO.File.WriteAllBytes(path, contents);
}
Run Code Online (Sandbox Code Playgroud)
小智 76
您需要在 bitbucket 控制台上创建“应用程序密码”。在您的头像->个人设置->访问管理->应用密码下。创建应用程序密码并记下。
完成后,打开 git bash 并使用 - 设置远程源
git remote set-url origin https://<Your_Account_Name>:<App_Password>@bitbucket.org/<Your_Account_Name>/<Repo_Name>.git
Run Code Online (Sandbox Code Playgroud)
mh8*_*020 27
由于问题是“我如何访问存储库” - 也许这对某人有用:
您还可以使用 Bitbucket“应用程序密码”通过 HTTPS 使用 Git。
git clone https://USERNAME:APP_PASSWORD@bitbucket.org/OWNER/REPO.git
Run Code Online (Sandbox Code Playgroud)
(或者,如果您想避免以明文形式存储密码::APP_PASSWORD在上面的 URL 中
省略,只需在 Git 提示时提供应用程序密码。)
这可能对 CI 有用(尽管 Git over SSH 可能更好)。
Wal*_*uch 25
您可以按如下方式执行此要求:
curl -u "walery2iq:<appPassword>" "https://api.bitbucket.org/2.0/repositories/[yourRepo]"
Run Code Online (Sandbox Code Playgroud)
这里重要的是 - 使用您的用户名,而不是电子邮件地址.重要的是因为登录bitbucket本身你使用的是电子邮件,而不是用户名:D
您可以在此处找到您的用户名:
设置 - >帐户设置 - >用户名
见图.
小智 20
如果您有两步验证,我可以克隆但不能推送。这对我来说很有效,使用 git 而不是curl:
git push https://<username>:<GENERATED-APP-PASS>@bitbucket.org/<username>/<repo>.git
Run Code Online (Sandbox Code Playgroud)
在https://bitbucket.org/account/admin/app-passwords生成应用程序密码
小智 8
git remote set-url origin https://[app-label]:[app-password]@bitbucket.org/[your-repo].git
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6925 次 |
| 最近记录: |