'How to access bitbucket using app password
I have created an app password as explained here
But now, how do I access the repository using this app password?
What will be the url?
Can someone direct me to a page showing an example please?
The below is a code for github. How do I do it for 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);
}
Update
Go to Personal Settings and then App Passwords as shown below.
Solution 1:[1]
You can perform this requsest as follows:
curl -u "walery2iq:<appPassword>" "https://api.bitbucket.org/2.0/repositories/[yourRepo]"
Important thing here - use your username, not e-mail address. Important because for login on bitbucket itself you are using e-mail and not username :D
You can find your username here:
Settings -> Account settings -> Username
See picture.
Solution 2:[2]
Since the question was "how do I access the repository" - maybe this is useful for somebody:
You can also use a Bitbucket "App Password" to use Git over HTTPS.
git clone https://USERNAME:[email protected]/OWNER/REPO.git
(Or, if you want to avoid storing the password in plaintext:
Omit :APP_PASSWORD
in the URL above, and just provide the App Password when prompted by Git.)
This may be useful for CI (although Git over SSH might be better).
Solution 3:[3]
You need to create your "app password" on bitbucket console. Under your Avatar ->Personal Settings ->Access Management ->App Password. Create app password and note it down.
Once done, open your git bash and set the remote origin using -
git remote set-url origin https://<Your_Account_Name>:<App_Password>@bitbucket.org/<Your_Account_Name>/<Repo_Name>.git
Solution 4:[4]
If you have a 2-step verification I was able to clone but not to make a push. This worked for me using git instead of curl:
git push https://<username>:<GENERATED-APP-PASS>@bitbucket.org/<username>/<repo>.git
Generate an app password at https://bitbucket.org/account/admin/app-passwords
Solution 5:[5]
git remote set-url origin https://[app-label]:[app-password]@bitbucket.org/[your-repo].git
Solution 6:[6]
Git uses libcurl
under the hood so one might keep password in ~/.netrc
file:
machine bitbucket.org login USER password PAZZ
and avoid leaking password to shell history:
git clone https://[email protected]/$WORKSPACE/$REPO.git
Solution 7:[7]
This worked for me, check use credential helper from git settings.
That is, preferences-> version control-> To git -> use credential helper
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Walery Strauch |
Solution 2 | mh8020 |
Solution 3 | General Grievance |
Solution 4 | Victor |
Solution 5 | ShSehati |
Solution 6 | gavenkoa |
Solution 7 | victor |