Skip to content

GitHub Authentication: Support expiring GitHub tokens brokered through Microsoft Entra #335183

Closed

Description

@TylerLeonhardt

Problem

The GitHub Authentication extension can broker GitHub access tokens through a signed-in Microsoft Entra account. These exchanged GitHub tokens have a finite lifetime, but the extension previously treated them like ordinary persisted GitHub OAuth tokens with no known expiry or renewal path.

Once an exchanged token expired, consumers could lose authentication and fall back to an interactive sign-in prompt even though the Microsoft account was still signed in and could silently mint a replacement.

Desired behavior

  • Keep the exchanged token's absolute expiry internally.
  • Return its current relative lifetime through AuthenticationSession.expiresIn.
  • Recompute the remaining lifetime whenever a cached session is returned.
  • Silently renew Microsoft-brokered GitHub sessions before expiry, including the one-hour threshold required by the Copilot SDK.
  • Coalesce concurrent renewal attempts.
  • Retain a still-valid token when proactive renewal fails transiently, and only remove the session after the token actually expires.
  • Leave ordinary persisted GitHub OAuth sessions unchanged when their expiry is unknown.

Implementation

Implemented by #334418, including mocked coverage for initial exchange, restore, cached lifetime recomputation, renewal, and transient renewal failures.

Activity

  1. added this to the 1.138.0 milestone on Sep 9, 2026
  2. added
    feature-request
    authentication-github
    copilot-cli-agent
    agent-host
    on Sep 9, 2026
  3. added
    unreleased
    insiders-released
    verification-needed
    and removed
    unreleased
    on Sep 9, 2026
  4. TylerLeonhardt commented on Oct 1, 2026

    @TylerLeonhardt
    MemberAuthor

    Verification steps

    You need a work machine where your Microsoft work account is signed in to the OS, and an account that has Continue with Microsoft (you probably do, see #339157).

    1. Run code-insiders --transient and sign in with Continue with Microsoft.
    2. Use Copilot in the Agents window so you know the sign-in works.
    3. Leave that window open until the end of the day, or until the next day. Don't close it: a transient window starts over when it's closed, and restarting VS Code gets a fresh token anyway.
    4. Come back and use Copilot again, both in an existing Agents session and a new one.

    That's it. If you're never asked to sign in again and nothing fails with an auth error, it works. The token lives for about 6 hours, so by then it has been renewed at least once. To confirm, look for Renewed session in the GitHub Authentication output channel.

  5. added
    verified
    on Oct 5, 2026
  6. locked and limited conversation to collaborators on Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

agent-hostauthentication-githubcopilot-cli-agentfeature-requestinsiders-releasedverification-neededverified

Type

No type

Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions