Repository navigation
Create/Revoke Personal Access Tokens #2531
Description
Activity
- addedcoreThis issue is not accepting PRs from outside contributorsThis issue is not accepting PRs from outside contributors
on Dec 7, 2020 Currently there's no API for revoking tokens and it's expected that users will manage this themselves. This is really frustrating for any organization, we obviously can't rely on users to open up their browsers and check which tokens to revoke, we need to build this into scripts.
The ability to revoke tokens would really help a lot.
Reacted by Mislav Marohnić, VonC, Roni Lichtman, Chad Bentz, Tyler Schoppe, Glenn 'devalias' Grant, jvlasblom, Nicholas Gibson, Sebastian "Sebbie" Silbermann, Carl Boettiger and 4 moreAny updates on a projected timeline for this addition? Thanks!
Was just setting up a new work environment and was surprised to find that the
ghCLI doesn't support creating/listing/revoking tokens from it.
We still plan to do this, but we are a way off still. We might need to first convert our OAuth app to a "GitHub App" before we can improve the user experience of minting tokens with specific privileges and expiration.
@aslilac For authenticating Docker, see this workaround: #5150 (comment)
Originally posted by @mislav in #3855 (comment)
Reacted by Kim JanshedenEven if the token couldn't be created through the CLI due to missing API's/etc at the moment, having a command that even directs us to do so in the web UI in the meantime would aid in discovery/etc.
Particularly given the URL can be guided with url params (unsure if there are others besides
description):https://github.com/settings/tokens/new?description=useful-forks%20(no%20scope%20required)Reacted by acrewdson@0xdevalias The
scopesquery parameter seems to work:
https://github.com/settings/tokens/new?description=useful-forks&scopes=repo:invite,read:public_keyReacted by Glenn 'devalias' Grant, Taylor Monacelli, acrewdson and Jérémie TarotThe
scopesquery parameter seems to work:Ah, nice. I thought i'd seen that done, but couldn't remember the specifics for it.
For anyone who doesn't want to wait until this gets an official API and implementation, here is a 3rd party CLI tool and Python library to create, list and delete fine-grained tokens (which are a bit different from classic personal access tokens, but if anyone wants, I can probably write a similar thing for the classic ones...): https://smheidrich.gitlab.io/github-fine-grained-token-client/
This is achieved by simulating the requests that would be triggered by a user clicking through the web interface. Obviously this approach can't be very stable because the web interface is subject to change without warning, so I'd strongly recommend against using this for anything critical. Intended usage is to just run this locally to make creating tokens less annoying, a bit faster and scriptable.
@samcoe @williammartin: I think this issue might need to be closed due to the limitations of GitHub APIs around PATs and uncertainty when such APIs will materialize. GitHub has heard feedback around this area, however I haven't seen anything on the GitHub public roadmap to set reasonable expectations for this. Though tools like those mentioned #2531 (comment) are plausible, I don't recommend we implement something out of band of official GitHub APIs.
My recommendation for this issue is that we close it until there's a better GitHub API story around token management.
Thoughts?
Reacted by Jérémie Tarot and Kim JanshedenPersonally I don't close issues just because of a lack of upstream support; as that tends to have the effect of hiding the demand/interest/etc among the noise.
I would usually add a 'blocked by upstream' type tag to signal it's not something that can be actively worked on, then leave it open.
/2c
Reacted by Shahriar Heidrich, James Sandford, C33SAR, Gloss Genius Integrations, Cesare Rossi, Simon Holloway, Jérémie Tarot, Kim Jansheden and Daniel Evers- addedplatformProblems with the GitHub platform rather than the CLI clientProblems with the GitHub platform rather than the CLI client
on Sep 26, 2023 @andyfeller I would agree with @0xdevalias with marking it
blockedby theplatformbut leaving it open so it is easier to for users to find.Reacted by Andy Feller and James SandfordHow can we surface this issue? it doesn't make sense to leave it behind for 3 years
Reacted by Kim JanshedenHow can we surface this issue? it doesn't make sense to leave it behind for 3 years
@ydekel6 : I can assure you that this has been raised to Engineering and Product. I don't think there is much else the GitHub CLI team can do independently as there are broader API and security design issues that go beyond our team.
My advice is for you to engage the broader GitHub community through one of the 🔄API and Webhooks discussions that have touched on this. This is the best place for you to engage directly with the Engineering and Product hubbers around our APIs.
Reacted by Glenn 'devalias' GrantAdditional commentary. The ability. for Enterprise customers, to generate tokens on behalf of a user account could be beneficial. Especially in an environment where service accounts (bots) are used to setup integrations and PATs are required but enabling 2FA on the EMU platform would effectively disable those accounts from creating their own PAT by the respective owning team.
I too deeply need an API for issuing and revoking PATs.
Reacted by mzorzella-simeon, Tzahi Ben Shabat, Joel Wenzel, SavvasM1, Matt Mulligan, Matthew Palmer, Dhruv Patel and Dmytro Pasko+1
Reacted by Oliver MannionYeah, as an Org-admin i'd like to ability to revoke leaked classic (and fine-grained) tokens of our users without having to wait for the user themselves to do this.
So we can stick any leaked credentials in a script to auto-revoke these credentials.Any new about this feature?
The API used to have this option, but it seems to have been removed in 2020. See StackOverflow answers.
Reacted by Dmytro Pasko, Kim Jansheden, Roman and cbrown- marked personal-access-tokens access can't be updated! #11348 as a duplicate of this issue
on Jul 25, 2025 - addedpitchpitched internally for prioritisationpitched internally for prioritisation
on Mar 10, 2026 I just experienced a weirdness wherein GitHub's token manager (PATs, OAuth, Apps) at
https://github.com/settings/applicationsdidn't revoke a GitHub CLI OAuth token after hitting the revoke button several times.So, I revoked it using the API:
curl -L -X POST https://api.github.com/credentials/revoke \ -d '{"credentials": ["<<token>>"]}'I first tried using
gh. One seemingly cannot do call with, e.g.jo credentials=$(jo -a "${TOKEN_TO_BE_REVOKED}") | gh api /credentials/revoke --input -1 with theghcommand because the API request must be anonymous2 andghseemingly cannot be used anonymously once logged in.Side note: I went to add a command
gh credentials revoke <token token…>but saw in the contributing guide that issues marked with thecorelabel are not open for public submissions…Footnotes
-
https://github.com/jpmens/jo ||
brew install jo-> creates JSON safely/mindlessly ↩ -
Response:
↩{ "message": "This API endpoint can only be accessed anonymously.", "documentation_url": "https://docs.github.com/credentials/revoke#revoke-a-list-of-credentials", "status": "403" }
-
- added a commit that references this issue
on Jul 29, 2026
Describe the feature or problem you’d like to solve
I would like to be able to create and revoke personal access tokens from the CLI
Proposed solution
Calling
gh token createwill create a new token and output the token valueCalling
gh token revokewill revoke the token passed in