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

Enhance extension to leverage gh auth session #26

Open
andyfeller opened this issue Jun 1, 2022 · 4 comments
Open

Enhance extension to leverage gh auth session #26

andyfeller opened this issue Jun 1, 2022 · 4 comments

Comments

@andyfeller
Copy link
Contributor

andyfeller commented Jun 1, 2022

Problem

One of the helpful aspects of GitHub CLI extensions is their ability to delegate authorization issues to be handled by gh auth. This allows interpreted and precompiled extensions to delegate this responsibility, focusing on the core functionality.

With initially running the gh-repo-stats extension, it prompted and required a personal access token (PAT) when this was already setup via standard GH CLI methods.

$ gh repo-stats --org $(whoami) 

######################################################
######################################################
############# GitHub repo list and sizer #############
######################################################
######################################################


------------------------------------------------------
Please create a GitHub Personal Access Token used to gather
information from your Organization, with a scope of 'repo',
followed by [ENTER]:
(note: your input will NOT be displayed)

Request

It would be nice if the extension was enhanced in a way where it did not need my PAT explicitly. Looking at the underlying interpreted script, I think this might be doable if all of the curl calls were instead leveraging gh api or other gh subcommands itself.

@Chocrates
Copy link

Strangely that didn't happen to me. I wonder if it was using my GITHUB_TOKEN that is in my environment?
Anyhow, could gh auth allow this to use a github app for authentication so we get 15k requests per hour?
Is the gh tool even the right spot to make that request?

@andyfeller
Copy link
Contributor Author

@Chocrates : 🤔 that is a really good question, essentially:

Can gh auth leverage a GitHub App private key and installation information to authenticate for a one-time token?

That aside, gh would pick up on your GITHUB_TOKEN as explained in https://cli.github.com/manual/gh_help_environment

@3nassale7

This comment has been minimized.

@vagabond2522
Copy link

Problem

One of the helpful aspects of GitHub CLI extensions is their ability to delegate authorization issues to be handled by gh auth. This allows interpreted and precompiled extensions to delegate this responsibility, focusing on the core functionality.

With initially running the gh-repo-stats extension, it prompted and required a personal access token (PAT) when this was already setup via standard GH CLI methods.

$ gh repo-stats --org $(whoami) 

######################################################
######################################################
############# GitHub repo list and sizer #############
######################################################
######################################################


------------------------------------------------------
Please create a GitHub Personal Access Token used to gather
information from your Organization, with a scope of 'repo',
followed by [ENTER]:
(note: your input will NOT be displayed)

Request

It would be nice if the extension was enhanced in a way where it did not need my PAT explicitly. Looking at the underlying interpreted script, I think this might be doable if all of the curl calls were instead leveraging gh api or other gh subcommands itself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants