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 Authorization: Bearer scheme for internal api calls #11727
Describe the feature or problem you’d like to solve
I am a customer at Uber. We would like to enable the GitHub CLI for our enterprise but are unable to do so because our internal proxy requires the Bearer scheme in the Authorization: headers for any api calls. This however is not supported by the GitHub CLI despite being noted in the API docs here.
I am unsure if the Bearer scheme works with all currently supported token forms using the Authorization: token scheme.
But if it would be possible to maintain backwards compatibility with the current token scheme while adding support for Bearer, it would greatly help.
Proposed solution
Add support for GH_AUTH_SCHEME environment variable in AddAuthTokenHeader
Defaults to 'token' for backward compatibility
Set to 'Bearer' to use Bearer token authentication format
Thank you for your issue! We have categorized it as a feature 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.
As you pointed out a big question is whether all API endpoints would work with the Bearer scheme. Maybe the answer is yes, but I'm not sure and this needs further investigation/comms.
Also, even with Bearer for all requests, there are still special cases when the Authorization header is not applicable (e.g. when logging in). I'm not sure how your setup handles such cases (maybe it's just fine if there's no auth header, idk).
Anyway, I'll keep this issue open since there's already some context to this.
As long as the Authorization header follows standard Bearer or Basic schemes, I don’t see an issue.
For login flows, the CLI supports both PATs and OAuth tokens, which are typically passed as Bearer tokens and should be fine.
For OAuth (both web and device flows), the token exchange appears to happen via a POST request with a payload to obtain the token, rather than relying on pre-existing Authorization headers. That also seems appropriate.
That said, there could be edge cases or GitHub-specific behaviors that aren’t obvious from the CLI codebase alone.
I'm just bringing across the context from #12828 into this issue because it's valuable.
Describe the feature or problem you'd like to solve
The GitHub CLI currently uses the token scheme for Authorization headers (Authorization: token <TOKEN>), while GitHub's official API documentation and examples consistently use the standard Bearer scheme (Authorization: Bearer <TOKEN>).
This creates three problems:
Blocks JWT/GitHub App authentication: GitHub's REST API documentation explicitly states: "if you are passing a JSON web token (JWT), you must use Authorization: Bearer". The current token scheme prevents proper GitHub App integration.
Blocks enterprise proxy/SSO integrations: Many enterprises use proxy patterns where SSO issues internal bearer tokens, a proxy exchanges them for GitHub tokens via GitHub App authentication, and forwards requests to GitHub's API. The token scheme forces enterprises to build custom workarounds, maintain CLI forks, or avoid the CLI entirely because GitHub Apps expect Bearer per OAuth 2.0 standards.
Diverges from GitHub's own standards: All official GitHub API curl examples use Bearer, and GitHub's own tools (Octokit, GitHub Actions) use Bearer as the standard. The CLI is inconsistent with the broader GitHub ecosystem.
Proposed solution
Change all Authorization headers from token scheme to Bearer scheme:
Removes barriers for enterprise proxy/SSO integrations
Aligns with GitHub's documented API standards and examples
Complies with RFC 6750 (OAuth 2.0 Bearer Token Usage)
Matches GitHub's own tooling ecosystem (Octokit, Actions, etc.)
Future-proofs the CLI as GitHub continues OAuth 2.0 standardization
Compatibility: According to GitHub's documentation, both schemes are currently accepted for personal access tokens, so this change is non-breaking for individual users while unlocking enterprise and GitHub App scenarios.
Files affected:
api/http_client.go
pkg/cmd/auth/shared/login_flow.go
pkg/cmd/auth/shared/oauth_scopes.go
Associated test files
Additional context
This issue is related to closed PR #11667 by @nishithsoni, which was closed pending proper justification per contribution guidelines.
Blocks JWT/GitHub App authentication: GitHub's REST API documentation explicitly states: "if you are passing a JSON web token (JWT), you must use Authorization: Bearer". The current token scheme prevents proper GitHub App integration.
We don't really intend for gh to support JWT authentication out of the box. As far as I'm aware, the number of endpoints that accept JWTs are very small, and primarily related to managing installation tokens (which are supported) so effectively it would only be relevant for custom gh api commands, which allow headers to be overridden anyway. Every other command would be broken.
Blocks enterprise proxy/SSO integrations: Many enterprises use proxy patterns where SSO issues internal bearer tokens, a proxy exchanges them for GitHub tokens via GitHub App authentication, and forwards requests to GitHub's API. The token scheme forces enterprises to build custom workarounds, maintain CLI forks, or avoid the CLI entirely because GitHub Apps expect Bearer per OAuth 2.0 standards.
I think it's fair for us to find a solution in gh, but it's not clear to me how big a blocker this is for proxies. Is the issue that you don't want to build logic into your proxy to sometimes look for Authorization: token ... to get the internal Bearer token for exchange?
I'm currently waiting to get access to those internal tickets linked in the original description.
Diverges from GitHub's own standards: All official GitHub API curl examples use Bearer, and GitHub's own tools (Octokit, GitHub Actions) use Bearer as the standard. The CLI is inconsistent with the broader GitHub ecosystem.
Sort of true? Octokit uses token unless a JWT is being passed. Actions is a bit too broad for me to know exactly what you are referring to. I do agree with the docs point though, and that's probably the most salient.
Change all Authorization headers from token scheme to Bearer scheme:
Between the CLI and the API, I don't think there's much of a risk in this change. However, I am concerned that if we make this change we'll run into the opposite problem, where proxies might be expecting Authorization headers of the current format, since it has been that way for many years.
Digging deeper into the Proxy/SSO flow and how it works for us today:
Proxy Behavior
Our proxy layer (Envoy/Nginx) is fairly simple. It accepts an Authorization header with only two supported schemes:
Bearer
Basic
Any other token type (e.g., Authorization: token ...) is not recognized and will be rejected.
SSO Flow
The user completes MFA authentication in the browser.
The device that initiated SSO receives an SSO token (Bearer), valid for a limited duration (e.g., ~24 hours).
This SSO Bearer token is sent to the Nginx/Envoy proxy.
The proxy authenticates the user and forwards the request to a GitHub aware proxy.
The GitHub aware proxy performs a token exchange:
It maps the authenticated SSO identity to a GitHub App user token.
This works only if the user has previously authorized the GitHub App (Prerequisite for user).
CLI Integration
In our setup:
We provide a wrapper around the gh CLI to abstract SSO details and configure the host appropriately.
From our perspective, gh CLI can only operate using a Bearer token.
There is no support for other token schemes in our flow.
Therefore, using an Authorization header of type token (instead of Bearer) will not work, since the Envoy/Nginx proxy does not recognize that scheme. Given it's global proxy for the whole company, we don't really have much control to say add token scheme into that layer for us to use it as Bearer token.
I wonder if we could use Bearer behind some feature flag that we could enable in host configuration?
@nishithsoni feel free to add additional details on CLI wrapper set-up and how we plan to configure underlying Auth/Configs for gh CLI.
I think folks may want to use it internally, so likely down the line someone will ask for them. @nishithsoni what's our plan here? Are we enabling them?
we'll run into the opposite problem, where proxies might be expecting Authorization headers of the current format, since it has been that way for many years.
@williammartin@behinddwalls In order to keep this backwards compatible and not introduce any breaking changes, I had implemented the change behind a built-in envvar (i.e. GH_USE_BEARER_AUTH=1) similar to a feature flag.
If there isn't much of a risk with the change and would still support existing token types, I see no reason that we cannot to add this Bearer token support.
I think folks may want to use it internally, so likely down the line someone will ask for them. @nishithsoni what's our plan here? Are we enabling them?
Hadn't given extensions much thought but this would also require Bearer Auth scheme. We may be able to disable it as a last resort, but I'd like to support extensions as long as there is no other blockers.
This will also give us the extensibility of developing our own extensions on top of GH or giving other internal users the ability to build on top of the platform.
This change also needs to be in the go-gh library that is used by gh extensions such as gh stack. Being able to make the same change in gh-cli and go-gh would be ideal.
Activity
github-actions commentedon Sep 12, 2025
Thank you for your issue! We have categorized it as a feature 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.
babakks commentedon Sep 25, 2025
Thanks for opening the issue, @nishithsoni! 🙏
As you pointed out a big question is whether all API endpoints would work with the
Bearerscheme. Maybe the answer is yes, but I'm not sure and this needs further investigation/comms.Also, even with
Bearerfor all requests, there are still special cases when theAuthorizationheader is not applicable (e.g. when logging in). I'm not sure how your setup handles such cases (maybe it's just fine if there's no auth header, idk).Anyway, I'll keep this issue open since there's already some context to this.
Bearerscheme for Authorization headers to align with GitHub APIs and enable JWT support #12828 as a duplicate of this issuebehinddwalls commentedon Mar 4, 2026
As long as the Authorization header follows standard Bearer or Basic schemes, I don’t see an issue.
For login flows, the CLI supports both PATs and OAuth tokens, which are typically passed as Bearer tokens and should be fine.
For OAuth (both web and device flows), the token exchange appears to happen via a POST request with a payload to obtain the token, rather than relying on pre-existing Authorization headers. That also seems appropriate.
That said, there could be edge cases or GitHub-specific behaviors that aren’t obvious from the CLI codebase alone.
Ref.: https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/authorizing-oauth-apps#device-flow
williammartin commentedon Mar 4, 2026
I'm just bringing across the context from #12828 into this issue because it's valuable.
Describe the feature or problem you'd like to solve
The GitHub CLI currently uses the
tokenscheme for Authorization headers (Authorization: token <TOKEN>), while GitHub's official API documentation and examples consistently use the standardBearerscheme (Authorization: Bearer <TOKEN>).This creates three problems:
Blocks JWT/GitHub App authentication: GitHub's REST API documentation explicitly states: "if you are passing a JSON web token (JWT), you must use Authorization: Bearer". The current
tokenscheme prevents proper GitHub App integration.Blocks enterprise proxy/SSO integrations: Many enterprises use proxy patterns where SSO issues internal bearer tokens, a proxy exchanges them for GitHub tokens via GitHub App authentication, and forwards requests to GitHub's API. The
tokenscheme forces enterprises to build custom workarounds, maintain CLI forks, or avoid the CLI entirely because GitHub Apps expectBearerper OAuth 2.0 standards.Diverges from GitHub's own standards: All official GitHub API curl examples use
Bearer, and GitHub's own tools (Octokit, GitHub Actions) useBeareras the standard. The CLI is inconsistent with the broader GitHub ecosystem.Proposed solution
Change all Authorization headers from
tokenscheme toBearerscheme:Current:
Proposed:
Benefits:
Compatibility: According to GitHub's documentation, both schemes are currently accepted for personal access tokens, so this change is non-breaking for individual users while unlocking enterprise and GitHub App scenarios.
Files affected:
api/http_client.gopkg/cmd/auth/shared/login_flow.gopkg/cmd/auth/shared/oauth_scopes.goAdditional context
This issue is related to closed PR #11667 by @nishithsoni, which was closed pending proper justification per contribution guidelines.
References:
williammartin commentedon Mar 4, 2026
Responding to the individual points:
We don't really intend for
ghto support JWT authentication out of the box. As far as I'm aware, the number of endpoints that accept JWTs are very small, and primarily related to managing installation tokens (which are supported) so effectively it would only be relevant for customgh apicommands, which allow headers to be overridden anyway. Every other command would be broken.I think it's fair for us to find a solution in
gh, but it's not clear to me how big a blocker this is for proxies. Is the issue that you don't want to build logic into your proxy to sometimes look forAuthorization: token ...to get the internal Bearer token for exchange?I'm currently waiting to get access to those internal tickets linked in the original description.
Sort of true? Octokit uses
tokenunless a JWT is being passed. Actions is a bit too broad for me to know exactly what you are referring to. I do agree with the docs point though, and that's probably the most salient.Between the CLI and the API, I don't think there's much of a risk in this change. However, I am concerned that if we make this change we'll run into the opposite problem, where proxies might be expecting
Authorizationheaders of the current format, since it has been that way for many years.Let's keep this issue moving and get this resolved for y'all. Do you use
ghCLI extensions at all? One thing that comes to mind is that the previously closed PR would only adjust the token scheme forgh, but not extensions built usinggo-gh: https://github.com/cli/go-gh/blob/55692c6b904c06e3c01870fa81b326c2d0c88123/pkg/api/http_client.go#L182behinddwalls commentedon Mar 4, 2026
Digging deeper into the Proxy/SSO flow and how it works for us today:
Proxy Behavior
Our proxy layer (Envoy/Nginx) is fairly simple. It accepts an
Authorizationheader with only two supported schemes:Any other token type (e.g.,
Authorization: token ...) is not recognized and will be rejected.SSO Flow
CLI Integration
In our setup:
ghCLI to abstract SSO details and configure the host appropriately.ghCLI can only operate using a Bearer token.Therefore, using an
Authorizationheader of typetoken(instead ofBearer) will not work, since the Envoy/Nginx proxy does not recognize that scheme. Given it's global proxy for the whole company, we don't really have much control to say addtokenscheme into that layer for us to use it asBearertoken.I wonder if we could use
Bearerbehind some feature flag that we could enable inhostconfiguration?@nishithsoni feel free to add additional details on CLI wrapper set-up and how we plan to configure underlying Auth/Configs for
ghCLI.I think folks may want to use it internally, so likely down the line someone will ask for them. @nishithsoni what's our plan here? Are we enabling them?
nishithsoni commentedon Mar 4, 2026
@williammartin @behinddwalls In order to keep this backwards compatible and not introduce any breaking changes, I had implemented the change behind a built-in envvar (i.e. GH_USE_BEARER_AUTH=1) similar to a feature flag.
If there isn't much of a risk with the change and would still support existing token types, I see no reason that we cannot to add this
Bearertoken support.Hadn't given extensions much thought but this would also require
BearerAuth scheme. We may be able to disable it as a last resort, but I'd like to support extensions as long as there is no other blockers.This will also give us the extensibility of developing our own extensions on top of GH or giving other internal users the ability to build on top of the platform.
nishithsoni commentedon May 8, 2026
This change also needs to be in the go-gh library that is used by gh extensions such as gh stack. Being able to make the same change in gh-cli and go-gh would be ideal.
https://github.com/cli/go-gh/blob/55692c6b904c06e3c01870fa81b326c2d0c88123/pkg/api/http_client.go#L182