From 1e4441e0180763717af71b694fe3a4a04f39881c Mon Sep 17 00:00:00 2001 From: Matt Cooper Date: Fri, 5 Jun 2020 09:54:09 -0400 Subject: [PATCH] bearer != basic --- docs/repos/git/includes/personal-access-tokens.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/repos/git/includes/personal-access-tokens.md b/docs/repos/git/includes/personal-access-tokens.md index 8fee050b0b8..eb473af3690 100644 --- a/docs/repos/git/includes/personal-access-tokens.md +++ b/docs/repos/git/includes/personal-access-tokens.md @@ -136,7 +136,7 @@ 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: @@ -144,7 +144,7 @@ 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: @@ -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:
-Authorization: Basic BASE64USERNAME:PATSTRING +Authorization: Bearer BASE64_USERNAME_PAT_STRING
Here it is in C# using the HttpClient class.
@@ -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))));