Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/repos/git/includes/personal-access-tokens.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,15 @@ On Linux or macOS, in Bash, you can type:
```bash
MY_PAT=yourPAT # replace "yourPAT" with your actual PAT
B64_PAT=$(echo "pat:$MY_PAT" | base64)
git -c http.extraHeader="Authorization: Basic ${B64_PAT}" clone https://dev.azure.com/yourOrgName/yourProjectName/_git/yourRepoName
git -c http.extraHeader="Authorization: Bearer ${B64_PAT}" clone https://dev.azure.com/yourOrgName/yourProjectName/_git/yourRepoName
```

On Windows, you can do something similar in PowerShell:

```powershell
$MyPat = 'yourPAT'
$B64Pat = [Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes($MyPat))
git -c http.extraHeader="Authorization: Basic $B64Pat" clone https://dev.azure.com/yourOrgName/yourProjectName/_git/yourRepoName
git -c http.extraHeader="Authorization: Bearer $B64Pat" clone https://dev.azure.com/yourOrgName/yourProjectName/_git/yourRepoName
```

To keep your token more secure, use credential managers so you don't have to enter your credentials every time. We recommend the following credential managers:
Expand All @@ -164,7 +164,7 @@ curl -u username[:{personalaccesstoken}] https://dev.azure.com/{organization}/_a

If you wish to provide the PAT through an HTTP header, first convert it to a Base64 string (the following example shows how to convert to Base64 using C#). The resulting string can then be provided as an HTTP header in the following format:
<br/>
<code>Authorization: Basic BASE64USERNAME:PATSTRING</code>
<code>Authorization: Bearer BASE64_USERNAME_PAT_STRING</code>
<br/>
Here it is in C# using the <a href="/previous-versions/visualstudio/hh193681(v=vs.118)" data-raw-source="[HttpClient class](/previous-versions/visualstudio/hh193681(v=vs.118))">HttpClient class</a>.
<br/>
Expand All @@ -181,7 +181,7 @@ public static async void GetBuilds()
client.DefaultRequestHeaders.Accept.Add(
new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));

client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic",
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer",
Convert.ToBase64String(
System.Text.ASCIIEncoding.ASCII.GetBytes(
string.Format("{0}:{1}", "", personalaccesstoken))));
Expand Down