Skip to content

Commit dd2dcbc

Browse files
Per-session GitHub authentication for all SDK languages, plus update runtime and permissions to match (#1124)
1 parent b4ef955 commit dd2dcbc

64 files changed

Lines changed: 4631 additions & 811 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/auth/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ Use an OAuth GitHub App to authenticate users through your application and pass
110110
**How it works:**
111111
1. User authorizes your OAuth GitHub App
112112
2. Your app receives a user access token (`gho_` or `ghu_` prefix)
113-
3. Pass the token to the SDK via `githubToken` option
113+
3. Pass the token to the SDK via `gitHubToken` option
114114

115115
**SDK Configuration:**
116116

@@ -121,7 +121,7 @@ Use an OAuth GitHub App to authenticate users through your application and pass
121121
import { CopilotClient } from "@github/copilot-sdk";
122122

123123
const client = new CopilotClient({
124-
githubToken: userAccessToken, // Token from OAuth flow
124+
gitHubToken: userAccessToken, // Token from OAuth flow
125125
useLoggedInUser: false, // Don't use stored CLI credentials
126126
});
127127
```
@@ -299,7 +299,7 @@ BYOK allows you to use your own API keys from model providers like Azure AI Foun
299299

300300
When multiple authentication methods are available, the SDK uses them in this priority order:
301301

302-
1. **Explicit `githubToken`** - Token passed directly to SDK constructor
302+
1. **Explicit `gitHubToken`** - Token passed directly to SDK constructor
303303
2. **HMAC key** - `CAPI_HMAC_KEY` or `COPILOT_HMAC_KEY` environment variables
304304
3. **Direct API token** - `GITHUB_COPILOT_API_TOKEN` with `COPILOT_API_URL`
305305
4. **Environment variable tokens** - `COPILOT_GITHUB_TOKEN``GH_TOKEN``GITHUB_TOKEN`

docs/setup/backend-services.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ Pass individual user tokens when creating sessions. See [GitHub OAuth](./github-
290290
app.post("/chat", authMiddleware, async (req, res) => {
291291
const client = new CopilotClient({
292292
cliUrl: "localhost:4321",
293-
githubToken: req.user.githubToken,
293+
gitHubToken: req.user.githubToken,
294294
useLoggedInUser: false,
295295
});
296296

docs/setup/github-oauth.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ sequenceDiagram
2626
GH-->>App: Access token (gho_xxx)
2727
2828
App->>SDK: Create client with token
29-
SDK->>CLI: Start with githubToken
29+
SDK->>CLI: Start with gitHubToken
3030
CLI->>API: Request (as user)
3131
API-->>CLI: Response
3232
CLI-->>SDK: Result
@@ -124,7 +124,7 @@ import { CopilotClient } from "@github/copilot-sdk";
124124
// Create a client for an authenticated user
125125
function createClientForUser(userToken: string): CopilotClient {
126126
return new CopilotClient({
127-
githubToken: userToken,
127+
gitHubToken: userToken,
128128
useLoggedInUser: false, // Don't fall back to CLI login
129129
});
130130
}
@@ -373,7 +373,7 @@ For GitHub Enterprise Managed Users, the flow is identical — EMU users authent
373373
// No special SDK configuration needed for EMU
374374
// Enterprise policies are enforced server-side by GitHub
375375
const client = new CopilotClient({
376-
githubToken: emuUserToken, // Works the same as regular tokens
376+
gitHubToken: emuUserToken, // Works the same as regular tokens
377377
useLoggedInUser: false,
378378
});
379379
```
@@ -438,7 +438,7 @@ const clients = new Map<string, CopilotClient>();
438438
function getClientForUser(userId: string, token: string): CopilotClient {
439439
if (!clients.has(userId)) {
440440
clients.set(userId, new CopilotClient({
441-
githubToken: token,
441+
gitHubToken: token,
442442
useLoggedInUser: false,
443443
}));
444444
}

docs/troubleshooting/compatibility.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ The Copilot SDK communicates with the CLI via JSON-RPC protocol. Features must b
5555
| Create workspace file | `session.rpc.workspace.createFile()` | Create file in workspace |
5656
| **Authentication** | | |
5757
| Get auth status | `getAuthStatus()` | Check login state |
58-
| Use token | `githubToken` option | Programmatic auth |
58+
| Use token | `gitHubToken` option | Programmatic auth |
5959
| **Connectivity** | | |
6060
| Ping | `client.ping()` | Health check with server timestamp |
6161
| Get server status | `client.getStatus()` | Protocol version and server info |

docs/troubleshooting/debugging.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ var client = new CopilotClient(new CopilotClientOptions
268268

269269
```typescript
270270
const client = new CopilotClient({
271-
githubToken: process.env.GITHUB_TOKEN,
271+
gitHubToken: process.env.GITHUB_TOKEN,
272272
});
273273
```
274274
</details>

dotnet/src/Client.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,8 @@ public async Task<CopilotSession> CreateSessionAsync(SessionConfig config, Cance
513513
RequestElicitation: config.OnElicitationRequest != null,
514514
Traceparent: traceparent,
515515
Tracestate: tracestate,
516-
ModelCapabilities: config.ModelCapabilities);
516+
ModelCapabilities: config.ModelCapabilities,
517+
GitHubToken: config.GitHubToken);
517518

518519
var response = await InvokeRpcAsync<CreateSessionResponse>(
519520
connection.Rpc, "session.create", [request], cancellationToken);
@@ -638,7 +639,8 @@ public async Task<CopilotSession> ResumeSessionAsync(string sessionId, ResumeSes
638639
RequestElicitation: config.OnElicitationRequest != null,
639640
Traceparent: traceparent,
640641
Tracestate: tracestate,
641-
ModelCapabilities: config.ModelCapabilities);
642+
ModelCapabilities: config.ModelCapabilities,
643+
GitHubToken: config.GitHubToken);
642644

643645
var response = await InvokeRpcAsync<ResumeSessionResponse>(
644646
connection.Rpc, "session.resume", [request], cancellationToken);
@@ -1600,7 +1602,7 @@ public async Task<PermissionRequestResponseV2> OnPermissionRequestV2(string sess
16001602
{
16011603
return new PermissionRequestResponseV2(new PermissionRequestResult
16021604
{
1603-
Kind = PermissionRequestResultKind.DeniedCouldNotRequestFromUser
1605+
Kind = PermissionRequestResultKind.UserNotAvailable
16041606
});
16051607
}
16061608
}
@@ -1661,7 +1663,8 @@ internal record CreateSessionRequest(
16611663
bool? RequestElicitation = null,
16621664
string? Traceparent = null,
16631665
string? Tracestate = null,
1664-
ModelCapabilitiesOverride? ModelCapabilities = null);
1666+
ModelCapabilitiesOverride? ModelCapabilities = null,
1667+
string? GitHubToken = null);
16651668

16661669
internal record ToolDefinition(
16671670
string Name,
@@ -1716,7 +1719,8 @@ internal record ResumeSessionRequest(
17161719
bool? RequestElicitation = null,
17171720
string? Traceparent = null,
17181721
string? Tracestate = null,
1719-
ModelCapabilitiesOverride? ModelCapabilities = null);
1722+
ModelCapabilitiesOverride? ModelCapabilities = null,
1723+
string? GitHubToken = null);
17201724

17211725
internal record ResumeSessionResponse(
17221726
string SessionId,

0 commit comments

Comments
 (0)