Skip to content

Persist the issuing OAuth client ID for CLI token refresh #2383

Open

Description

@evanpurkhiser

The CLI stores OAuth access and refresh tokens with their issuing Sentry host. When it refreshes the token, it resolves the client ID again from the environment or build defaults. Sentry looks up the refresh token under the requesting OAuth application, so refresh fails with invalid_grant if the client ID differs from the one used at login.

This can happen when SENTRY_CLIENT_ID changes after login or when an agent handoff provides a different OAuth client ID. Initial authentication succeeds, then the session fails when the access token expires.

Store the issuing client ID with each OAuth credential and use it for refresh. Keep the existing client ID resolution as a fallback for credentials saved before the change. Add regression coverage for refreshing a credential whose client ID differs from the current default.

Follow-up to the review on #2320.

Activity

  1. linear-code commented on Nov 18, 2026

    @linear-code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions