{"meta":{"title":"Authentication","intro":"Das GitHub Copilot SDK unterstützt mehrere Authentifizierungsmethoden für unterschiedliche Anwendungsfälle. Wählen Sie die Methode aus, die ihrem Bereitstellungsszenario am besten entspricht.","product":"GitHub Copilot","breadcrumbs":[{"href":"/de/enterprise-cloud@latest/copilot","title":"GitHub Copilot"},{"href":"/de/enterprise-cloud@latest/copilot/how-tos","title":"Vorgehensweisen"},{"href":"/de/enterprise-cloud@latest/copilot/how-tos/copilot-sdk","title":"Copilot SDK"},{"href":"/de/enterprise-cloud@latest/copilot/how-tos/copilot-sdk/auth","title":"Authentication"},{"href":"/de/enterprise-cloud@latest/copilot/how-tos/copilot-sdk/auth/authenticate","title":"Authenticate"}],"documentType":"article"},"body":"# Authentication\n\nDas GitHub Copilot SDK unterstützt mehrere Authentifizierungsmethoden für unterschiedliche Anwendungsfälle. Wählen Sie die Methode aus, die ihrem Bereitstellungsszenario am besten entspricht.\n\n<!-- markdownlint-disable GHD046 GHD005 -->\n\n<!-- Suppressed: GHD046 (outdated release terminology), GHD005 (hardcoded data variable) -->\n\n## Authentifizierungsmethoden\n\n| Methode                                                                                                                    | Anwendungsfall                                                                        | Copilot Abonnement erforderlich                                |\n| -------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- | -------------------------------------------------------------- |\n| [GitHub Angemeldeter Benutzer](#github-signed-in-user)                                                                     | Interaktive Apps, bei denen sich Benutzer mit GitHub anmelden                         | Ja                                                             |\n| [GitHub OAuth-App](#github-oauth-app)                                                                                      | Apps, die im Namen von Benutzern über OAuth handeln                                   | Ja                                                             |\n| [Umgebungsvariablen](#environment-variables)                                                                               | CI/CD, Automatisierung, Server-zu-Server                                              | Ja                                                             |\n| [Server-zu-Server-Authentifizierung](/de/enterprise-cloud@latest/copilot/how-tos/copilot-sdk/auth/server-to-server-tokens) | Organisationszugeordnete Automatisierung und direkte Abrechnung über die Organisation | Kein Benutzerabonnement; Erforderliche Organisationsrichtlinie |\n| [Bring Your Own Key (BYOK)](/de/enterprise-cloud@latest/copilot/how-tos/copilot-sdk/auth/byok)                             | Verwenden Ihrer eigenen API-Schlüssel (Microsoft Foundry, OpenAI und mehr)            | No                                                             |\n\n## Angemeldeter GitHub-Benutzer\n\nDies ist die Standardauthentifizierungsmethode beim interaktiven Ausführen der Copilot CLI. Benutzer authentifizieren sich über GitHub OAuth-Gerätefluss, und das SDK verwendet ihre gespeicherten Anmeldeinformationen.\n\n**Funktionsweise**:\n\n1. Der Benutzer führt `copilot` CLI aus und meldet sich über GitHub OAuth an.\n2. Anmeldeinformationen werden sicher im Systemschlüsselbund gespeichert.\n3. SDK verwendet automatisch gespeicherte Anmeldeinformationen.\n\n**SDK-Konfiguration:**\n\n<div class=\"ghd-codetabs\">\n<div class=\"ghd-codetab\" data-lang=\"dotnet\" data-label=\".NET\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">.NET</div>\n\n```csharp\nusing GitHub.Copilot;\n\n// Default: uses logged-in user credentials\nawait using CopilotClient client = new();\n```\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"go\" data-label=\"Go\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">Go</div>\n\n```golang\nimport copilot \"github.com/github/copilot-sdk/go\"\n\n// Default: uses logged-in user credentials\nclient := copilot.NewClient(nil)\n```\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"java\" data-label=\"Java\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">Java</div>\n\n```java\nimport com.github.copilot.CopilotClient;\n\n// Default: uses logged-in user credentials\nvar client = new CopilotClient();\nclient.start().get();\n```\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"python\" data-label=\"Python\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">Python</div>\n\n```python\nfrom copilot import CopilotClient\n\n# Default: uses logged-in user credentials\nclient = CopilotClient()\nawait client.start()\n```\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"rust\" data-label=\"Rust\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">Rust</div>\n\n```rust\nuse github_copilot_sdk::{Client, ClientOptions};\n\n// Default: uses logged-in user credentials\nlet client = Client::start(ClientOptions::default()).await?;\n```\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"typescript\" data-label=\"TypeScript\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">TypeScript</div>\n\n```typescript\nimport { CopilotClient } from \"@github/copilot-sdk\";\n\n// Default: uses logged-in user credentials\nconst client = new CopilotClient();\n```\n\n</div>\n\n</div>\n\n**Wann verwenden:**\n\n* Desktopanwendungen, in denen Benutzer direkt interagieren\n* Entwicklungs- und Testumgebungen\n* Jedes Szenario, in dem sich ein Benutzer interaktiv anmelden kann\n\n## GitHub OAuth-App\n\nVerwenden Sie eine OAuth-GitHub-App, um Benutzer über Ihre Anwendung zu authentifizieren und ihre Anmeldeinformationen an das SDK zu übergeben. Auf diese Weise kann Ihre Anwendung Copilot API-Anforderungen im Namen von Benutzern vornehmen, die Ihre App autorisieren.\n\n**Funktionsweise**:\n\n1. Der Benutzer autorisiert Ihre OAuth-GitHub-App\n2. Ihre App empfängt ein Benutzerzugriffstoken (`gho_` oder `ghu_` Präfix)\n3. Übergeben des Tokens an das SDK über die Clientkonfiguration\n\n**SDK-Konfiguration:**\n\n<div class=\"ghd-codetabs\">\n<div class=\"ghd-codetab\" data-lang=\"dotnet\" data-label=\".NET\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">.NET</div>\n\n```csharp\nusing GitHub.Copilot;\n\nawait using var client = new CopilotClient(new CopilotClientOptions\n{\n    GitHubToken = userAccessToken,     // Token from OAuth flow\n    UseLoggedInUser = false,           // Don't use stored CLI credentials\n});\n```\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"go\" data-label=\"Go\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">Go</div>\n\n```golang\nimport copilot \"github.com/github/copilot-sdk/go\"\n\nclient := copilot.NewClient(&copilot.ClientOptions{\n    GitHubToken:       userAccessToken,      // Token from OAuth flow\n    UseLoggedInUser:   copilot.Bool(false),  // Don't use stored CLI credentials\n})\n```\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"java\" data-label=\"Java\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">Java</div>\n\n<!-- docs-validate: skip -->\n\n```java\nimport com.github.copilot.CopilotClient;\nimport com.github.copilot.rpc.*;\n\nvar client = new CopilotClient(new CopilotClientOptions()\n    .setGitHubToken(userAccessToken)  // Token from OAuth flow\n    .setUseLoggedInUser(false)        // Don't use stored CLI credentials\n);\nclient.start().get();\n```\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"python\" data-label=\"Python\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">Python</div>\n\n```python\nfrom copilot import CopilotClient\n\nclient = CopilotClient({\n    \"github_token\": user_access_token,  # Token from OAuth flow\n    \"use_logged_in_user\": False,        # Don't use stored CLI credentials\n})\nawait client.start()\n```\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"rust\" data-label=\"Rust\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">Rust</div>\n\n```rust\nuse github_copilot_sdk::{Client, ClientOptions};\n\nlet client = Client::start(\n    ClientOptions::default()\n        .with_github_token(user_access_token)\n        .with_use_logged_in_user(false),\n).await?;\n```\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"typescript\" data-label=\"TypeScript\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">TypeScript</div>\n\n```typescript\nimport { CopilotClient } from \"@github/copilot-sdk\";\n\nconst client = new CopilotClient({\n    gitHubToken: userAccessToken,  // Token from OAuth flow\n    useLoggedInUser: false,        // Don't use stored CLI credentials\n});\n```\n\n</div>\n\n</div>\n\n**Unterstützte Tokentypen:**\n\n* `gho_` – OAuth-Benutzerzugriffstoken\n* `ghu_` – GitHub App-Benutzerzugriffstoken\n* `github_pat_` – Feinkörnige persönliche Zugriffstoken\n\n**Nicht unterstützt:**\n\n* `ghp_` - Klassische persönliche Zugriffstoken (veraltet)\n\n**Wann verwenden:**\n\n* Webanwendungen, in denen sich Benutzer über GitHub anmelden\n* SaaS-Anwendungen, die auf Copilot aufbauen\n* Jede Mehrbenutzeranwendung, in der Sie Anforderungen im Namen verschiedener Benutzer stellen müssen\n\nWeitere Informationen findest du unter [Einrichtung von GitHub OAuth](/de/enterprise-cloud@latest/copilot/how-tos/copilot-sdk/setup/github-oauth).\n\n## Umgebungsvariablen\n\nFür Automatisierungs-, CI/CD-Pipelines und Server-zu-Server-Szenarien können Sie sich mithilfe von Umgebungsvariablen authentifizieren.\n\nInformationen zur vom Unternehmen zugewiesenen Automatisierung, die das persönliche Zugriffstoken eines Benutzers nicht verwenden sollte, finden Sie unter [Server-zu-Server-Authentifizierung](/de/enterprise-cloud@latest/copilot/how-tos/copilot-sdk/auth/server-to-server-tokens).\n\n**Unterstützte Umgebungsvariablen (in Prioritätsreihenfolge):**\n\n1. `COPILOT_GITHUB_TOKEN` – Empfohlen für explizite Copilot Nutzung\n2. `GH_TOKEN` - GitHub CLI kompatibel\n3. `GITHUB_TOKEN` - GitHub Actions kompatibel\n\n**Funktionsweise**:\n\n1. Festlegen einer der unterstützten Umgebungsvariablen mit einem gültigen Token\n2. Das SDK erkennt und verwendet das Token automatisch.\n\n**SDK-Konfiguration:**\n\nEs sind keine Codeänderungen erforderlich. Das SDK erkennt automatisch Umgebungsvariablen:\n\n<div class=\"ghd-codetabs\">\n<div class=\"ghd-codetab\" data-lang=\"dotnet\" data-label=\".NET\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">.NET</div>\n\n```csharp\nusing GitHub.Copilot;\n\n// Token is read from environment variable automatically\nawait using CopilotClient client = new();\n```\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"go\" data-label=\"Go\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">Go</div>\n\n```golang\nimport copilot \"github.com/github/copilot-sdk/go\"\n\n// Token is read from environment variable automatically\nclient := copilot.NewClient(nil)\n```\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"java\" data-label=\"Java\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">Java</div>\n\n```java\nimport com.github.copilot.CopilotClient;\n\n// Token is read from environment variable automatically\nvar client = new CopilotClient();\nclient.start().get();\n```\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"python\" data-label=\"Python\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">Python</div>\n\n```python\nfrom copilot import CopilotClient\n\n# Token is read from environment variable automatically\nclient = CopilotClient()\nawait client.start()\n```\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"rust\" data-label=\"Rust\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">Rust</div>\n\n```rust\nuse github_copilot_sdk::{Client, ClientOptions};\n\n// Token is read from environment variable automatically\nlet client = Client::start(ClientOptions::default()).await?;\n```\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"typescript\" data-label=\"TypeScript\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">TypeScript</div>\n\n```typescript\nimport { CopilotClient } from \"@github/copilot-sdk\";\n\n// Token is read from environment variable automatically\nconst client = new CopilotClient();\n```\n\n</div>\n\n</div>\n\n**Wann verwenden:**\n\n* CI/CD-Pipelines (GitHub Actions, Jenkins und mehr)\n* Automatisiertes Testen\n* Serverseitige Anwendungen mit Dienstkonten\n* Entwicklung, wenn Sie die interaktive Anmeldung nicht verwenden möchten\n\n## Bring Your Own Key (BYOK)\n\nBYOK ermöglicht es Ihnen, Ihre eigenen API-Schlüssel von Modellanbietern wie Microsoft Foundry, OpenAI oder Anthropic zu verwenden. Dadurch wird GitHub Copilot Authentifizierung vollständig umgangen.\n\n**Wichtige Vorteile:**\n\n* Kein GitHub Copilot Abonnement erforderlich\n* Verwenden von Enterprise-Modellbereitstellungen\n* Direkte Abrechnung mit Ihrem Modellanbieter\n* Unterstützung für Microsoft Foundry-, OpenAI-, Anthropic- und OpenAI-kompatible Endpunkte\n\n**Ausführliche Informationen finden Sie im [Bring Your Own Key (BYOK)](/de/enterprise-cloud@latest/copilot/how-tos/copilot-sdk/auth/byok)**, einschließlich:\n\n* Setup von Microsoft Foundry\n* Anbieterkonfigurationsoptionen\n* Einschränkungen und Überlegungen\n* Vollständige Codebeispiele\n\n## Authentifizierungspriorität\n\nWenn mehrere Authentifizierungsmethoden verfügbar sind, verwendet das SDK sie in dieser Prioritätsreihenfolge:\n\n1. **Explizit `gitHubToken`** – Token, das direkt an den SDK-Client oder die Sitzungskonfiguration übergeben wird\n2. **Direktes API-Token** - `GITHUB_COPILOT_API_TOKEN` mit `COPILOT_API_URL`\n3. **Umgebungsvariablen-Token** - `COPILOT_GITHUB_TOKEN` → `GH_TOKEN` → `GITHUB_TOKEN`\n4. **Gespeicherte OAuth-Anmeldeinformationen** – Aus vorheriger `copilot` CLI-Anmeldung\n5. **GitHub CLI** - `gh auth` Anmeldeinformationen\n\nÜbergeben Sie für den Mehrbenutzer-Servermodus für jede Sitzung ein eigenes `gitHubToken`, damit jede Sitzung unter der richtigen GitHub-Identität ausgeführt wird; siehe [Mandantenfähigkeit und Serverbereitstellungen](/de/enterprise-cloud@latest/copilot/how-tos/copilot-sdk/setup/multi-tenancy).\n\n## Deaktivieren der automatischen Anmeldung\n\nUm zu verhindern, dass das SDK automatisch gespeicherte Anmeldeinformationen oder `gh` CLI-Authentifizierung verwendet, konfigurieren Sie es so, dass der Fallback des angemeldeten Benutzers deaktiviert wird:\n\n<div class=\"ghd-codetabs\">\n<div class=\"ghd-codetab\" data-lang=\"dotnet\" data-label=\".NET\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">.NET</div>\n\n```csharp\nawait using var client = new CopilotClient(new CopilotClientOptions\n{\n    UseLoggedInUser = false,  // Only use explicit tokens\n});\n```\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"go\" data-label=\"Go\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">Go</div>\n\n```golang\nclient := copilot.NewClient(&copilot.ClientOptions{\n    UseLoggedInUser: copilot.Bool(false),  // Only use explicit tokens\n})\n```\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"java\" data-label=\"Java\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">Java</div>\n\n```java\nimport com.github.copilot.CopilotClient;\nimport com.github.copilot.rpc.*;\n\nvar client = new CopilotClient(new CopilotClientOptions()\n    .setUseLoggedInUser(false)  // Only use explicit tokens\n);\nclient.start().get();\n```\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"python\" data-label=\"Python\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">Python</div>\n\n```python\nclient = CopilotClient({\n    \"use_logged_in_user\": False,  # Only use explicit tokens\n})\n```\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"rust\" data-label=\"Rust\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">Rust</div>\n\n```rust\nuse github_copilot_sdk::{Client, ClientOptions};\n\nlet client = Client::start(\n    ClientOptions::default().with_use_logged_in_user(false),\n).await?;\n```\n\n</div>\n\n<div class=\"ghd-codetab\" data-lang=\"typescript\" data-label=\"TypeScript\"><div class=\"ghd-codetab-fallback-label\" role=\"heading\" aria-level=\"3\">TypeScript</div>\n\n```typescript\nconst client = new CopilotClient({\n    useLoggedInUser: false,  // Only use explicit tokens\n});\n```\n\n</div>\n\n</div>\n\n## Nächste Schritte\n\n* [Bring Your Own Key (BYOK)](/de/enterprise-cloud@latest/copilot/how-tos/copilot-sdk/auth/byok) – Erfahren Sie, wie Sie Ihre eigenen API-Schlüssel verwenden.\n* [Erstellen Sie Ihre erste Copilot-gestützte App](/de/enterprise-cloud@latest/copilot/how-tos/copilot-sdk/getting-started) – Erstellen Ihrer ersten Copilot-basierten App\n* [Verwenden von MCP-Servern mit dem GitHub Copilot SDK](/de/enterprise-cloud@latest/copilot/how-tos/copilot-sdk/features/mcp) – Herstellen einer Verbindung mit externen Tools"}