git-ecosystem/git-credential-manager · error · ArgumentException

Bitbucket DC OAuth Client ID must be defined

Error message

Bitbucket DC OAuth Client ID must be defined

What it means

BitbucketOAuth2Client.GetClientId reads the OAuth client ID from the Git credential config (DataCenterConstants.GitConfiguration.Credential.OAuthClientId under the credential section). If no value is stored there, it cannot construct the OAuth2 authorization request and throws ArgumentException. Bitbucket Data Center requires an admin-provisioned OAuth client for the app-password/OAuth flow.

Solutions

  1. Set the client ID in Git config: git config --global credential.bitbucketDCOAuthClientId <your-client-id>
  2. Verify the key name and credential section scope matches the repository host (use credential.<url>.bitbucketDCOAuthClientId for per-host config).
  3. Have the Bitbucket DC admin create an OAuth application (incoming link) and supply both client ID and secret.

Example fix

// before: throws because no client ID configured
// after:
$ git config --global credential.bitbucketDCOAuthClientId 0a1b2c3d4e5f
$ git config --global credential.bitbucketDCOAuthClientSecret my-secret
Defensive patterns

Strategy: validation

Validate before calling

$ git config --get credential.bitbucketDCOAuthClientId || echo "client id missing"
# C#: bool ok = settings.TryGetSetting(Constants.GitConfiguration.Credential.SectionName,
#     DataCenterConstants.GitConfiguration.Credential.OAuthClientId, out _);

Try / catch

try { await oauth2Client.GetCredentialAsync(); } catch (ArgumentException ex) when (ex.Message.Contains("Client ID")) { /* report missing config, point admin to OAuth app setup */ }

Prevention

When it happens

Trigger: Calling the Bitbucket DC OAuth2 credential flow (GetCredentialAsync via BitbucketOAuth2Client) when `credential.bitbucketDCOAuthClientId` (DataCenterConstants...OAuthClientId) is not set in the Git configuration.

Common situations: Fresh GCM install against a Bitbucket Data Center server without the required OAuth client config; admin never provisioned an OAuth application; config written under the wrong section/hostname scope; upgrades where DC-specific keys were never migrated.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


AI-assisted analysis of git-ecosystem/git-credential-manager@e8ce762cd0 (2026-09-11). Data as JSON: /api/errors/51b7f8e98af3e07f. Report an issue: GitHub.

Appendix: source

Thrown at src/Atlassian.Bitbucket/DataCenter/BitbucketOAuth2Client.cs:38

        public override IEnumerable<string> Scopes => new string[] {
            DataCenterConstants.OAuthScopes.PublicRepos,
            DataCenterConstants.OAuthScopes.RepoRead,
            DataCenterConstants.OAuthScopes.RepoWrite
        };

        private static string GetClientId(ISettings settings)
        {
            // Check for developer override value
            if (settings.TryGetSetting(
                DataCenterConstants.EnvironmentVariables.OAuthClientId,
                Constants.GitConfiguration.Credential.SectionName, DataCenterConstants.GitConfiguration.Credential.OAuthClientId,
                out string clientId))
            {
                return clientId;
            }

            throw new ArgumentException("Bitbucket DC OAuth Client ID must be defined");
        }

        private static Uri GetRedirectUri(ISettings settings)
        {
            // Check for developer override value
            if (settings.TryGetSetting(
                DataCenterConstants.EnvironmentVariables.OAuthRedirectUri,
                Constants.GitConfiguration.Credential.SectionName, DataCenterConstants.GitConfiguration.Credential.OAuthRedirectUri,
                out string redirectUriStr) && Uri.TryCreate(redirectUriStr, UriKind.Absolute, out Uri redirectUri))
            {
                return redirectUri;
            }

            return DataCenterConstants.OAuth2RedirectUri;
        }

        private static string GetClientSecret(ISettings settings)
        {

View on GitHub (pinned to e8ce762cd0)