{"record":{"id":"778a33cf2868344d","repo":"git-ecosystem/git-credential-manager","slug":"no-authentication-mode-selected","errorCode":null,"errorMessage":"No authentication mode selected!","messagePattern":"No authentication mode selected!","errorType":"exception","errorClass":"Trace2Exception","httpStatus":null,"severity":"error","filePath":"src/Core/GenericHostProvider.cs","lineNumber":358,"sourceCode":"                supportedModes &= ~OAuthAuthenticationModes.DeviceCode;\n            }\n\n            // Prompt the user to select a mode\n            OAuthAuthenticationModes mode = await _oauth.GetAuthenticationModeAsync(remoteUri.ToString(), supportedModes);\n\n            OAuth2TokenResult tokenResult;\n            switch (mode)\n            {\n                case OAuthAuthenticationModes.Browser:\n                    tokenResult = await _oauth.GetTokenByBrowserAsync(client, config.Scopes);\n                    break;\n\n                case OAuthAuthenticationModes.DeviceCode:\n                    tokenResult = await _oauth.GetTokenByDeviceCodeAsync(client, config.Scopes);\n                    break;\n\n                default:\n                    throw new Trace2Exception(_context.Trace2, \"No authentication mode selected!\");\n            }\n\n            // Store the refresh token if we have one\n            if (!string.IsNullOrWhiteSpace(tokenResult.RefreshToken))\n            {\n                _context.CredentialStore.AddOrUpdate(refreshService, oauthUser, tokenResult.RefreshToken);\n            }\n\n            return new GitCredential(oauthUser, tokenResult.AccessToken);\n        }\n\n        /// <summary>\n        /// Check if the user permits checking for Windows Integrated Authentication.\n        /// </summary>\n        /// <remarks>\n        /// Checks the explicit 'GCM_ALLOW_WINDOWSAUTH' setting and also the legacy 'GCM_AUTHORITY' setting iif equal to \"basic\".\n        /// </remarks>\n        private bool IsWindowsAuthAllowed","sourceCodeStart":340,"sourceCodeEnd":376,"githubUrl":"https://github.com/git-ecosystem/git-credential-manager/blob/e8ce762cd04b4100ae637b5fbf39ef9d0a96561e/src/Core/GenericHostProvider.cs#L340-L376","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Set a supported authentication mode, e.g. `git config --global credential.https://github.com.oauthAuthModes browser` (or devicecode).","Check environment variables like GCM_OAUTH_AUTHMODES for invalid or empty values and remove/correct them.","Check Trace2 output for the recorded exception and confirm which mode value was parsed.","Upgrade Git Credential Manager if the configured mode should be supported in a newer version."],"exampleFix":"// before\ngit config --global credential.https://github.com.oauthAuthModes \"\"\n// after\ngit config --global credential.https://github.com.oauthAuthModes browser","handlingStrategy":"validation","validationCode":"var mode = ParseOAuthMode(config.OAuthAuthenticationModes);\nif (mode is not (OAuthAuthenticationModes.Browser or OAuthAuthenticationModes.DeviceCode))\n{\n    throw new InvalidOperationException($\"Unsupported OAuth auth mode: {config.OAuthAuthenticationModes}\");\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    var cred = await provider.GenerateCredentialAsync(input);\n}\ncatch (Trace2Exception ex)\n{\n    logger.LogError(ex, \"No supported OAuth authentication mode configured; set oauthAuthModes to browser or devicecode.\");\n}","preventionTips":["Always set credential.<host>.oauthAuthModes explicitly to a supported value.","Never leave OAuth mode configuration empty or set it to values like 'none'.","Validate configuration at startup with a supported-modes allowlist.","Read Trace2 output when authentication fails to see the parsed mode."],"tags":["oauth","authentication","configuration","git-credential-manager"],"backgroundTag":"invalid-enum-value","analyzedSha":"e8ce762cd04b4100ae637b5fbf39ef9d0a96561e","analyzedAt":"2026-09-11T17:15:08.753Z","contentChangedAt":"2026-09-11T17:15:08.753Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}