Skip to content

Refresh tokens for GitHub. #789

Open

Description

@adam-azarchs

I'm not 100% sure, but as far as I can tell, at the moment the GitHub OAuth2 flow is generating long-lived tokens. It would be nice to have the ability to use short-lived credentials + refresh tokens. That flow appears to already be mandatory for BitBucket; it would be nice to have that as at least an option for GitHub as well.

Short-lived oauth tokens with refresh tokens are more secure than long-lived tokens because if your token gets exfiltrated then it'll expire quickly, and if the attacker uses the refresh token then you should at least be able to detect that quickly. I'm sure long-lived tokens are fine for many situations, but for organizations which are more paranoid, or where the risk of exposure is higher (e.g. situations where developers are logging in from a shared machine) it would be helpful to have the ability to enforce that higher level of security.

Implementation-wise this should be pretty straightforward, since it's already supported for BitBucket and GitLab, though it might require making a separate client secret for GCM in this mode, since it looks from the docs like GitHub's configuration on whether oauth credentials are short-lived or not is on a per-application basis.

Activity

  1. hickford commented on Jul 13, 2022

    @hickford
    Contributor

    Good question. Might access token expiry even have prevented or reduced the 2022 stolen OAuth token attack? FWIW GitHub Apps offer expiring access tokens as an optional feature. Why not offer expiring access tokens for OAuth too?

    Interestingly GitLab recently removed non-expiring access tokens. This is breaking change for apps which don't support refresh flow -- users would have to reauthenticate every 2 hours.

  2. added this to the Future milestone on Apr 10, 2023
  3. hickford commented on Apr 11, 2023

    @hickford
    Contributor

    @adam-azarchs You might find this comparison of OAuth servers interesting

  4. mjcheetham commented on Jan 8, 2026

    @mjcheetham
    Contributor

    This issue requires migration to the GitHub App infrastructure, which has several issues when using a public client app rather than a confidential client (specifically around org installation and consent).

    Blocked on GitHub platform enhancements.

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

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions