You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support multiple fine-grained tokens for gh auth switch #12888
Describe the feature or problem you’d like to solve
Fine-grained tokens are a great way to limit access to automated tools and AIs by repository and permission. However, each fine-grained token can only be associated with a single GitHub organization. That means that if you want to use a single GitHub CLI instance to interact with multiple organizations, you can't. Since the CLI is limited to a single token, it also means that concurrent processes can't be using the CLI to communicate to different organizations in parallel.
Proposed solution
Add --add-token as an option when using --with-token. When specified, this will add the new token instead of replacing it. As well, add the organization name or ID to the hosts.yaml file for the token so the gh CLI tool can automatically use the right token.
Thank you for your issue! We have categorized it as an enhancement (feature or improvement) request, and it has been added to our backlog. In doing so, we are not committing to implementing this feature at this time, but, we will consider it for future releases based on community feedback and our own product roadmap.
Unless you see the
help wantedContributions welcome
label, we are not currently looking for external contributions for this feature.
If you come across this issue and would like to see it implemented, please add a thumbs up! This will help us prioritize the feature. Please only comment if you have additional information or viewpoints to contribute.
I was able to work around this by using https://direnv.net/. However, it works best when you have project directories or git checkouts for the .envrc or .env file to exist in, which wouldn't help cases where a user is calling gh directly with nothing locally other than the gh args to identify what token to use.
I know it will not be merged but in case it helps i have implemented this branch: rastaman#1 (with Opus and Cursor) to implement what is described here. I have done it, and added a possibility to sync a fork with upstream from 2 auths, because my day-to-day employer disabled PAT and only allowed FAT and it brokes some of my workflows with gh. I really don't say it perfect but it does the job for me.
Activity
github-actions commentedon Mar 9, 2026
Thank you for your issue! We have categorized it as an enhancement (feature or improvement) request, and it has been added to our backlog. In doing so, we are not committing to implementing this feature at this time, but, we will consider it for future releases based on community feedback and our own product roadmap.
Unless you see the help wantedContributions welcome
label, we are not currently looking for external contributions for this feature.
If you come across this issue and would like to see it implemented, please add a thumbs up! This will help us prioritize the feature. Please only comment if you have additional information or viewpoints to contribute.
deviantintegral commentedon Mar 9, 2026
I was able to work around this by using https://direnv.net/. However, it works best when you have project directories or git checkouts for the
.envrcor.envfile to exist in, which wouldn't help cases where a user is callingghdirectly with nothing locally other than theghargs to identify what token to use.sharptank-au commentedon Apr 1, 2026
Having issues on
gh auth switchdoesn't pick up second account, it was stuck in the first authentificated account, any suggestions to fix that on macdocs(auth): add sample hosts.yml showing the multi-org schema change
rastaman commentedon Jul 23, 2026
I know it will not be merged but in case it helps i have implemented this branch: rastaman#1 (with Opus and Cursor) to implement what is described here. I have done it, and added a possibility to sync a fork with upstream from 2 auths, because my day-to-day employer disabled PAT and only allowed FAT and it brokes some of my workflows with gh. I really don't say it perfect but it does the job for me.
HtH, my 2 cents
feat(auth): support multiple fine-grained tokens per host (cli#12888)
docs(auth): add sample hosts.yml showing the multi-org schema change
feat(auth): support multiple fine-grained tokens per host (cli#12888)