Skip to content
This repository was archived by the owner on Jul 15, 2023. It is now read-only.

Commit e6793c5

Browse files
author
J Wyman
authored
Merge pull request #699 from whoisj/v1.17/fix-bitbucket
Fix Bitbucket Authentication
2 parents 44f1866 + f8b3707 commit e6793c5

File tree

4 files changed

+7
-10
lines changed

4 files changed

+7
-10
lines changed

Bitbucket.Authentication/Src/Authority.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public async Task<bool> ValidateCredentials(TargetUri targetUri, string username
166166
}
167167

168168
// If the basic authentication test failed then try again as OAuth
169-
if (await ValidateCredentials(targetUri, new Token(credentials.Password, TokenType.BitbucketPassword)))
169+
if (await ValidateCredentials(targetUri, new Token(credentials.Password, TokenType.BitbucketAccess)))
170170
{
171171
return true;
172172
}

Bitbucket.Authentication/Src/Rest/RestClient.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ public async Task<AuthenticationResult> TryGetUser(TargetUri targetUri, int requ
2626
Authorization = authorization,
2727
Timeout = TimeSpan.FromMilliseconds(requestTimeout),
2828
};
29-
var requestUri = targetUri.CreateWith(restRootUrl);
29+
30+
var apiUrl = new Uri(restRootUrl, UserUrl);
31+
var requestUri = targetUri.CreateWith(apiUrl);
3032

3133
using (var response = await Network.HttpGetAsync(requestUri, options))
3234
{

Microsoft.Alm.Authentication/Src/Network.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@ private HttpClient GetHttpClient(TargetUri targetUri, HttpMessageHandler handler
440440
switch (token.Type)
441441
{
442442
case TokenType.AzureAccess:
443+
case TokenType.BitbucketAccess:
443444
{
444445
// ADAL access tokens are packed into the Authorization header.
445446
httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Value);

Microsoft.Alm.Authentication/Src/TokenType.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,22 +60,16 @@ public enum TokenType
6060
[System.ComponentModel.Description("Test-only Token")]
6161
Test = 5,
6262

63-
/// <summary>
64-
/// Bitbucket Password Tokens.
65-
/// </summary>
66-
[System.ComponentModel.Description("Bitbucket Password Token")]
67-
BitbucketPassword = 6,
68-
6963
/// <summary>
7064
/// Bitbucket Access Tokens.
7165
/// </summary>
7266
[System.ComponentModel.Description("Bitbucket Access Token")]
73-
BitbucketAccess = 7,
67+
BitbucketAccess = 6,
7468

7569
/// <summary>
7670
/// Used to auto-refresh Bitbucket Access Tokens.
7771
/// </summary>
7872
[System.ComponentModel.Description("Bitbucket Refresh Token")]
79-
BitbucketRefresh = 8,
73+
BitbucketRefresh = 7,
8074
}
8175
}

0 commit comments

Comments
 (0)