{"record":{"id":"878ffb7bc0a6fa26","repo":"git-ecosystem/git-credential-manager","slug":"no-available-interaction-modes","errorCode":null,"errorMessage":"No available interaction modes.","messagePattern":"No available interaction modes\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Core/Authentication/Entra/EntraAuthentication.PublicClient.cs","lineNumber":300,"sourceCode":"            Context.Trace.WriteLine($\"Interaction mode overriden to '{mode}'.\");\n            interactionMode = mode;\n        }\n\n        switch (interactionMode)\n        {\n            // Try to use the most appropriate interaction mode available\n            case InteractionMode.Auto:\n                Context.Trace.WriteLine(\"Resolving interactive mode auto...\");\n                if (IsEmbeddedWebViewAvailable())\n                    goto case InteractionMode.EmbeddedWebView;\n\n                if (IsSystemWebViewAvailable())\n                    goto case InteractionMode.SystemWebView;\n\n                if (IsDeviceCodeAvailable())\n                    goto case InteractionMode.DeviceCode;\n\n                throw new InvalidOperationException(\"No available interaction modes.\");\n\n            case InteractionMode.EmbeddedWebView:\n                Context.Trace.WriteLine(\"Performing interactive authentication via embedded webview...\");\n                return await app.AcquireTokenInteractive(scopes)\n                    .WithUseEmbeddedWebView(true)\n                    .WithEmbeddedWebViewOptions(GetEmbeddedWebViewOptions())\n                    .ExecuteAsync(ct);\n\n            case InteractionMode.SystemWebView:\n                Context.Trace.WriteLine(\"Performing interactive authentication via system webview...\");\n                Context.Console.WriteInfo(\"opening browser to complete authentication...\");\n                return await app.AcquireTokenInteractive(scopes)\n                    .WithUseEmbeddedWebView(false)\n                    .WithSystemWebViewOptions(GetSystemWebViewOptions())\n                    .ExecuteAsync(ct);\n\n            case InteractionMode.DeviceCode:\n                Context.Trace.WriteLine(\"Performing interactive authentication via device code...\");","sourceCodeStart":282,"sourceCodeEnd":318,"githubUrl":"https://github.com/git-ecosystem/git-credential-manager/blob/e8ce762cd04b4100ae637b5fbf39ef9d0a96561e/src/Core/Authentication/Entra/EntraAuthentication.PublicClient.cs#L282-L318","documentation":"Thrown from GetTokenForUserInteractiveAsync when InteractionMode.Auto is requested (or defaulted) but none of the interactive mechanisms — embedded webview, system webview, or device code flow — are available on the current platform/configuration. The library cannot perform user interactive authentication at all, so it fails fast with this InvalidOperationException.","triggerScenarios":"Calling GetTokenForUserAsync (which resolves to GetTokenForUserInteractiveAsync) with InteractionMode.Auto on a headless environment (SSH session, CI runner, container) where no webview is available and the device code endpoint/flow is unavailable or disabled.","commonSituations":"Running GCM or a tool using this library on a headless Linux server, inside Docker, over SSH without a browser, or on a stripped-down platform where MSAL reports no supported broker/webview and device code flow is unavailable.","solutions":["Verify which modes are available with IsEmbeddedWebViewAvailable/IsSystemWebViewAvailable/IsDeviceCodeAvailable before requesting Auto mode.","Explicitly pass InteractionMode.DeviceCode and ensure device code flow is supported (network access to the device authorization endpoint).","Run in an environment with a browser or desktop session (GUI available) so a webview mode can be used.","Pre-authenticate on a machine with a browser and copy credentials/tokens to the headless environment."],"exampleFix":"// before\nvar token = await auth.GetTokenForUserAsync(scopes); // Auto -> throws on headless box\n// after\nvar token = await auth.GetTokenForUserAsync(scopes, Interaction: InteractionMode.DeviceCode);","handlingStrategy":"fallback","validationCode":"bool anyMode = IsEmbeddedWebViewAvailable() || IsSystemWebViewAvailable() || IsDeviceCodeAvailable();\nif (!anyMode) throw new InvalidOperationException(\"No interactive authentication available in this environment.\");","typeGuard":null,"tryCatchPattern":"try\n{\n    token = await auth.GetTokenForUserAsync(scopes);\n}\ncatch (InvalidOperationException ex) when (ex.Message == \"No available interaction modes.\")\n{\n    // fall back to device code flow or fail with a clear message\n    token = await auth.GetTokenForUserAsync(scopes, Interaction: InteractionMode.DeviceCode);\n}","preventionTips":["Detect headless environments (no DISPLAY/WAYLAND, SSH sessions) before requesting interactive auth.","Default to DeviceCode mode on servers and CI.","Pre-authenticate interactively on a machine with a browser and transfer credentials."],"tags":["authentication","entra","headless-environment","interactive-auth"],"backgroundTag":"unsupported-platform","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"}