Repository navigation
Open
Labels
coreThis issue is not accepting PRs from outside contributorsenhancementa request to improve CLIgh-authrelating to the gh auth commandmore-info-neededMore info needed from user/contributor
Description
Describe the feature or problem you’d like to solve
Currently the gh cli enables authentication against GitHub via two ways, going off my reading of the manual
- Personal Access Token
- OAuth apps
Another way to make calls against the GitHub API is via GitHub Apps. GitHub Apps have some different features from the above but, crucially, allow you to separate out the credential from a given service user. This can be valuable in cases such as CI systems, where you want something to last longer than the tenure of a specific employee, or to not have to leverage a service user which might have its own complexities depending on the organization.
Proposed solution
The proposed solution is to enable, in a CI pipeline, to be able to execute something like
./get-secret-from-secret-provider.sh > github-app-private-key.pem
# Validate the app id and private key
gh auth login --github-app-id 12345 --github-app-private-key github-app-private-key.pem
# Create a pull request, maybe
cd ./repo/
gh pr create --fill
# This would
# 1. look up the "installation id" from the app, maybe leveraging a cache
# 2. create an installation access token bound to the organization for the repository
# 3. do the operation as requested by the userAdditional context
I did look for an issue having already been created but did not find anything relevant
Reacted by Silvan Mosberger, Adam Weigert, Andre Silva, Stefan Kühnel, Andy Crain, sxm51, Hannes Gustafsson, Max Schmitt, Michael Mican, Joseph Macaranas and 10 more
Metadata
Metadata
Assignees
Labels
coreThis issue is not accepting PRs from outside contributorsenhancementa request to improve CLIgh-authrelating to the gh auth commandmore-info-neededMore info needed from user/contributor
Activity
MichaMican commentedon Mar 26, 2025
This would be super usefull!
andyfeller commentedon Jul 15, 2025
@abhishekmukherg : Firstly, I want to sincerely apologize for not engaging with this issue sooner. 🙇 The GitHub CLI maintainers are working to improve our backlog review processes to provide more timely and confident feedback for suggestions and bugs.
I would love to ask some questions to understand this use case as well as share some additional information you might find useful.
Questions
In your scenario, is
ghauthenticating a) as a GitHub App, b) as an app installation, c) on behalf of the user?Is this inside or outside a GitHub Actions workflow?
Are there any other
ghcommands that might be necessary with this support?Thoughts
The first question is important because it affects the complexity of the work as well as the REST endpoints or GraphQL queries/mutations you want to use:
If you need to authenticate as an app installation with access to repositories, there are 2 short term solutions while this issue awaits prioritization depending on whether you're using this in GitHub Actions:
actions/create-github-app-tokenaction can be used within GitHub Actions workflow:link-/gh-tokenGitHub CLI extension can be used locally or within GitHub Actions workflow:gh token generate \ --key ./.keys/private-key.pem \ --app-id 1122334 \ --installation-id 5566778Thanks to fellow hubber, @Link-, for this work! 🫶
The installation access token generated from either of these solutions can be used to authenticate as the GitHub App with access to repositories the GitHub App is installed in.
Finally, I can see several additional commands being needed around authenticating as an GitHub App installation:
stefankuehnel commentedon Aug 1, 2025
Hi @andyfeller,
Thanks so much for the detailed response and for taking the time to engage with this issue — really appreciate it! 🫶
While I’m not the original poster, I upvoted this issue because I think my use case closely aligns with theirs. I’d like to share my perspective and a demo I created to help clarify the need for this functionality.
My Use Case
I’m aiming to use a GitHub App as a replacement for Personal Access Tokens. GitHub Apps offer more fine-grained access controls and are decoupled from individual user accounts, which improves both security and maintainability.
My goal is to run the GitHub CLI externally — for example, in a Bash script on a remote server — to trigger workflows in a repository using a GitHub App. This would allow me to automate tasks securely and independently of GitHub Actions or user-scoped credentials.
Demo Setup
To illustrate this, I created an example organization
GH-CLI-8747containing two repositories:Example Workflow Dispatcher.example.ymlworkflow. Currently, this is done via theworkflow_dispatcher.ymlworkflow using theactions/create-github-app-tokencomposite action.What I'm Hoping For
The steps in the
workflow_dispatcher.ymlwork well inside GitHub Actions, but ideally, they should be supported directly by the GitHub CLI so that the same logic can seamlessly be executed externally — without relying on third-party extensions or custom GitHub App token generation scripts.In short, I’d love to see native CLI support for:
Thanks again for your detailed response. I hope this example helps clarify the need for this functionality. I’d be happy to provide additional feedback or collaborate further if helpful!
Best regards,
Stefan Kühnel
lkiii commentedon May 19, 2026
This would be really useful for automation.
I’d like to have a remote container with the gh installed that can perform actions on repositories. I’d also like the ability to grant the app the necessary permissions within my organization.
App tokens are much more flexible than PATs. PATs inherit the same permissions as the user who created them, which makes it hard to enforce strict access controls. For my use case, I’d like to configure precise permissions - for example mostly read-only access, with limited write permissions only where explicitly needed.
jessehouwing commentedon Sep 4, 2026
A good reason for this is the new throttling for anonymous access:
The recent change to redirect anonymous clones to authenticate (See #14329 and https://github.com/orgs/community/discussions/206581#discussioncomment-18269083) creates a cannondrum for users of ghe.com and competing platforms when they consume public repos as subtree, submodules or package manager dependencies (like npm git urls or terraform modules).
Requiring every user to create a public github account, then auth or mint an access token won't create a more secure github environment in most organizations.
It would be useful if these people could share an organization owned access key.
I propose the ability for gh to be able to authenticate as a github app (by passing installation id and secret) to mint a temporary token.
Similar to how many people are already doing this in github actions workflows using https://github.com/actions/create-github-app-token.
But then from the commandline and to store these in the credential manager storage as well.
Proposed solution
It will allow non-github clients to provide authenticated access to public github repos (linked to their organization's identity) without requiring every user to create their own personal github account or to setup EMU purely for the benefit of accessing public github repos in the above mentiond scenarios.
Additional context
Add any other context like screenshots or mockups are helpful, if applicable.
Reported issues so far for which this could help:
The poposed link-/gh-token extension looks promising, but for usage in enterprise context, especially given how sensitive tokens are, a native, official github owned solution is preferable.