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

No authentication mode selected!

Error message

No authentication mode selected!

What it means

GenericHostProvider.GetOAuthAccessToken switches over the configured OAuthAuthenticationModes (Browser, DeviceCode, etc.). If the configured mode matches none of the implemented cases, the default arm throws a Trace2Exception. This means the credential provider configuration selected an authentication mode the provider does not support.

Solutions

  1. Set a supported authentication mode, e.g. `git config --global credential.https://github.com.oauthAuthModes browser` (or devicecode).
  2. Check environment variables like GCM_OAUTH_AUTHMODES for invalid or empty values and remove/correct them.
  3. Check Trace2 output for the recorded exception and confirm which mode value was parsed.
  4. Upgrade Git Credential Manager if the configured mode should be supported in a newer version.

Example fix

// before
git config --global credential.https://github.com.oauthAuthModes ""
// after
git config --global credential.https://github.com.oauthAuthModes browser
Defensive patterns

Strategy: validation

Validate before calling

var mode = ParseOAuthMode(config.OAuthAuthenticationModes);
if (mode is not (OAuthAuthenticationModes.Browser or OAuthAuthenticationModes.DeviceCode))
{
    throw new InvalidOperationException($"Unsupported OAuth auth mode: {config.OAuthAuthenticationModes}");
}

Try / catch

try
{
    var cred = await provider.GenerateCredentialAsync(input);
}
catch (Trace2Exception ex)
{
    logger.LogError(ex, "No supported OAuth authentication mode configured; set oauthAuthModes to browser or devicecode.");
}

Prevention

When it happens

Trigger: Calling GenerateCredentialAsync when the resolved credential configuration (e.g. credential.<provider>.oauthAuthenticationModes or GCM_PROVIDER settings) yields an OAuthAuthenticationModes value that is not Browser, DeviceCode, or another explicitly handled case — e.g. an enum value of None or an unrecognized mode.

Common situations: Misconfigured GCM_OAUTH_AUTHMODES / credential.oauthAuthModes setting, a typo in configuration, an upgrade where a mode was removed or renamed, or configuration parsing producing OAuthAuthenticationModes.None because no mode was set.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


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

Appendix: source

Thrown at src/Core/GenericHostProvider.cs:358

                supportedModes &= ~OAuthAuthenticationModes.DeviceCode;
            }

            // Prompt the user to select a mode
            OAuthAuthenticationModes mode = await _oauth.GetAuthenticationModeAsync(remoteUri.ToString(), supportedModes);

            OAuth2TokenResult tokenResult;
            switch (mode)
            {
                case OAuthAuthenticationModes.Browser:
                    tokenResult = await _oauth.GetTokenByBrowserAsync(client, config.Scopes);
                    break;

                case OAuthAuthenticationModes.DeviceCode:
                    tokenResult = await _oauth.GetTokenByDeviceCodeAsync(client, config.Scopes);
                    break;

                default:
                    throw new Trace2Exception(_context.Trace2, "No authentication mode selected!");
            }

            // Store the refresh token if we have one
            if (!string.IsNullOrWhiteSpace(tokenResult.RefreshToken))
            {
                _context.CredentialStore.AddOrUpdate(refreshService, oauthUser, tokenResult.RefreshToken);
            }

            return new GitCredential(oauthUser, tokenResult.AccessToken);
        }

        /// <summary>
        /// Check if the user permits checking for Windows Integrated Authentication.
        /// </summary>
        /// <remarks>
        /// Checks the explicit 'GCM_ALLOW_WINDOWSAUTH' setting and also the legacy 'GCM_AUTHORITY' setting iif equal to "basic".
        /// </remarks>
        private bool IsWindowsAuthAllowed

View on GitHub (pinned to e8ce762cd0)