Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create/Revoke Personal Access Tokens #2531

Open
CalvinRodo opened this issue Dec 2, 2020 · 17 comments
Open

Create/Revoke Personal Access Tokens #2531

CalvinRodo opened this issue Dec 2, 2020 · 17 comments
Labels
blocked core This issue is not accepting PRs from outside contributors enhancement a request to improve CLI platform Problems with the GitHub platform rather than the CLI client

Comments

@CalvinRodo
Copy link

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 create will create a new token and output the token value
Calling gh token revoke will revoke the token passed in

TOKEN="$(gh token create --scope scope.json)" 
github-label-sync -a "$TOKEN" 
gh token revoke "$TOKEN"

### Additional context

Add any other context like screenshots or mockups are helpful, if applicable.
@CalvinRodo CalvinRodo added the enhancement a request to improve CLI label Dec 2, 2020
@Praveen9693

This comment has been minimized.

@samcoe samcoe added the core This issue is not accepting PRs from outside contributors label Dec 7, 2020
@insanitybit
Copy link

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.

@tylerschoppe
Copy link

Any updates on a projected timeline for this addition? Thanks!

@0xdevalias
Copy link

Was just setting up a new work environment and was surprised to find that the gh CLI 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)

@0xdevalias
Copy link

0xdevalias commented Nov 29, 2022

Even 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)

@mislav
Copy link
Contributor

mislav commented Nov 29, 2022

@0xdevalias The scopes query parameter seems to work:
https://github.com/settings/tokens/new?description=useful-forks&scopes=repo:invite,read:public_key

@0xdevalias
Copy link

The scopes query parameter seems to work:

Ah, nice. I thought i'd seen that done, but couldn't remember the specifics for it.

@asmayljlyly9

This comment was marked as spam.

@smheidrich
Copy link

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.

@andyfeller
Copy link
Contributor

@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?

@0xdevalias
Copy link

Personally 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

@samcoe samcoe added blocked platform Problems with the GitHub platform rather than the CLI client labels Sep 26, 2023
@samcoe
Copy link
Contributor

samcoe commented Sep 26, 2023

@andyfeller I would agree with @0xdevalias with marking it blocked by the platform but leaving it open so it is easier to for users to find.

@ydekel6
Copy link

ydekel6 commented Nov 12, 2023

How can we surface this issue? it doesn't make sense to leave it behind for 3 years

@andyfeller
Copy link
Contributor

andyfeller commented Nov 13, 2023

How 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.

@bchase-humana
Copy link

Additional 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.

@illrill
Copy link

illrill commented Feb 29, 2024

I too deeply need an API for issuing and revoking PATs.

@z-sourcecode
Copy link

+1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked core This issue is not accepting PRs from outside contributors enhancement a request to improve CLI platform Problems with the GitHub platform rather than the CLI client
Projects
None yet
Development

No branches or pull requests