Skip to content

Commit 686b584

Browse files
authored
Use OAuth tokens on DevBox by default for Azure Repos (#1245)
Update the default for `credential.azreposCredentialType` or `GCM_AZREPOS_CREDENTIALTYPE` to `oauth` when on Microsoft DevBox. #917
2 parents 61cd8e3 + 0a9a0c9 commit 686b584

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

docs/configuration.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -751,11 +751,13 @@ Credential: "git:https://[email protected]/example/myrepo" (user = bob)
751751

752752
Specify the type of credential the Azure Repos host provider should return.
753753

754-
Defaults to the value `pat`.
754+
Defaults to the value `pat`. In certain cloud hosted environments when using a
755+
work or school account, such as [Microsoft DevBox][devbox], the default value is
756+
`oauth`.
755757

756758
Value|Description
757759
-|-
758-
`pat` _(default)_|Azure DevOps personal access tokens
760+
`pat`|Azure DevOps personal access tokens
759761
`oauth`|Microsoft identity OAuth tokens (AAD or MSA tokens)
760762

761763
Here is more information about [Azure Access tokens][azure-tokens].

docs/environment.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -840,11 +840,13 @@ export GCM_MSAUTH_USEDEFAULTACCOUNT="false"
840840

841841
Specify the type of credential the Azure Repos host provider should return.
842842

843-
Defaults to the value `pat`.
843+
Defaults to the value `pat`. In certain cloud hosted environments when using a
844+
work or school account, such as [Microsoft DevBox][devbox], the default value is
845+
`oauth`.
844846

845847
Value|Description
846848
-|-
847-
`pat` _(default)_|Azure DevOps personal access tokens
849+
`pat`|Azure DevOps personal access tokens
848850
`oauth`|Microsoft identity OAuth tokens (AAD or MSA tokens)
849851

850852
More information about Azure Access tokens can be found [here][azure-access-tokens].

src/shared/Microsoft.AzureRepos/AzureReposHostProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,8 @@ private static string GetAccountNameForCredentialQuery(InputArguments input)
391391
/// <returns>True if Personal Access Tokens should be used, false otherwise.</returns>
392392
private bool UsePersonalAccessTokens()
393393
{
394-
// Default to using PATs
395-
const bool defaultValue = true;
394+
// Default to using PATs except on DevBox where we prefer OAuth tokens
395+
bool defaultValue = !PlatformUtils.IsDevBox();
396396

397397
if (_context.Settings.TryGetSetting(
398398
AzureDevOpsConstants.EnvironmentVariables.CredentialType,

0 commit comments

Comments
 (0)