github_auth
Class info¶
Classes¶
| Name | Children | Inherits |
|---|---|---|
| CopilotAuthBackend llmling_models.auth.github_auth GitHub Copilot device-code auth backend. |
||
| CopilotAuthResult llmling_models.auth.github_auth Result of Copilot authentication. |
||
| CopilotTokenStore llmling_models.auth.github_auth File-based token storage for Copilot OAuth. |
🛈 DocStrings¶
GitHub Copilot authentication helper.
Supports both github.com and GitHub Enterprise via device code flow. After login, exchanges the GitHub access token for a Copilot API token.
Based on the pi-mono implementation by badlogic.
CopilotAuthBackend
¶
Bases: ProviderAuthBackend
GitHub Copilot device-code auth backend.
Source code in src/llmling_models/auth/github_auth.py
455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 | |
CopilotAuthResult
¶
CopilotTokenStore
¶
File-based token storage for Copilot OAuth.
Source code in src/llmling_models/auth/github_auth.py
clear
¶
load
¶
Load stored credentials.
Source code in src/llmling_models/auth/github_auth.py
authenticate_copilot
¶
authenticate_copilot(
verbose: bool = True, enterprise_domain: str | None = None
) -> dict[str, str | float | None]
Authenticate with GitHub Copilot via device code flow.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
verbose
|
bool
|
Whether to print authentication status messages |
True
|
enterprise_domain
|
str | None
|
GitHub Enterprise domain (None for github.com) |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, str | float | None]
|
Dict with keys: github_token, copilot_token, base_url, expires_at, |
dict[str, str | float | None]
|
enterprise_domain |
Source code in src/llmling_models/auth/github_auth.py
copilot_auth_main
¶
Command-line entry point for Copilot authentication.
Source code in src/llmling_models/auth/github_auth.py
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 | |
get_copilot_base_url
¶
Get the Copilot API base URL.
Prefers extracting from the token's proxy-ep field, falls back to constructing from enterprise domain or default.
Source code in src/llmling_models/auth/github_auth.py
get_or_refresh_copilot_token
¶
get_or_refresh_copilot_token(
store: CopilotTokenStore | None = None,
) -> dict[str, str | float | None]
Get a valid Copilot token, refreshing if necessary.
The GitHub OAuth token doesn't expire, but the Copilot API token does. This refreshes the Copilot token using the stored GitHub token.
Source code in src/llmling_models/auth/github_auth.py
refresh_copilot_token
¶
refresh_copilot_token(
github_token: str, enterprise_domain: str | None = None
) -> dict[str, str | float | None]
Refresh the Copilot API token using the stored GitHub token.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
github_token
|
str
|
The GitHub OAuth access token |
required |
enterprise_domain
|
str | None
|
GitHub Enterprise domain (None for github.com) |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, str | float | None]
|
Dict with copilot_token, base_url, expires_at |