2016-10-06 64 views
3

访问到位桶作为解释here如何使用我创建一个应用程序密码应用密码

但现在,我该如何访问使用这个应用程序的密码库?
什么是网址?
有人可以指示我一个页面显示一个例子吗?

以下是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); 
} 
+0

你能发表一些解释吗? – inye

+0

@inye在问题中增加了一些细节 – VivekDev

+0

您询问了关于Bitbucket的问题,但您的代码引用了'githubToken'和'https:// github.com /'。你真的想用哪个系统? – Chris

回答

2

可以按如下方式执行此requsest:

curl -u "walery2iq:<appPassword>" "https://api.bitbucket.org/2.0/repositories/[yourRepo]" 

重要的东西在这里 - 用您的用户名,而不是电子邮件地址。 重要,因为在到位桶本身登录使用的是电子邮件,而不是用户名:d

你可以在这里找到你的用户名:

设置 - >帐户设置 - >用户名

看照片。

Use this username - not your mail address

相关问题