Skip to content

Decline invalid GitHub tokens #4980

@sergeibbb

Description

@sergeibbb

This is a follow-up of #4492

The problem

We can understand about many tokens that they are invalid because they are outdated (token.expiresAt is in the past), but GitHub tokens are not provided with expiration date, therefore we do not decline them by reason of expiration.

GKDev web page sends https://api.github.com/graphql: {"query":"query { rateLimit(dryRun: true) { __typename } }"} and by response they can show on the web-page that it's invalid:

{
  "message": "Bad credentials",
  "documentation_url": "https://docs.github.com/rest",
  "status": "401"
}
Image

Possible solution

Our options are:

  1. leave it on GitLens as is
  2. query GitHub for token validity in the same way as it's done on the web page.
  3. Convince GKDev team to retire invalid GitHub token on their side and do not send them to us, or at least let us know that they are invalid.
  4. Nuke the invalid token from GKDev. We can do following:
    • detect that the GitHub token is invalid
    • try to refresh with GKDev, if it succeeds—good, if it fails—go further. (maybe we can skip this step because probably it always fails)
    • kick the token away from GKDev. We can use this API endpoint to disconnect:

      Use this route to disconnect a token from GK, it will not invalidate the token on the providers end

    • open a piece of UI that would let user to reconnect GitHub.

According to this recent discussion it seems that we lean to the option 4.

Metadata

Metadata

Assignees

No one assigned

    Labels

    triageNeeds to be looked at

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions