GitHub: 407 "Proxy Authentication Required"
The 407 does not come from GitHub. A proxy between you and GitHub wants you to log in to it before it passes the request on. RFC 9110, section 15.5.8 defines it as similar to 401, but meaning that the client needs to authenticate itself in order to use a proxy for this request; the proxy must send a Proxy-Authenticate header with the challenge, and the client may repeat the request with a Proxy-Authorization header. So the fix is to give the tool that failed the proxy's address and your login for the proxy, not a new GitHub token.
Try it with curl first
This asks GitHub for a short line of text through the proxy (GitHub's Get the Zen of GitHub). Replace PROXY_HOST, PORT and PROXY_USER with the values from your administrator.
curl -i -x http://PROXY_HOST:PORT --proxy-user PROXY_USER:PROXY_PASSWORD https://api.github.com/zen
A line of text means the proxy and the login work. A 407 again means the proxy did not accept the login, or wants another method. The curl manual's options for this:
-x,--proxy[protocol://]host[:port]: use this proxy. With no protocol or withhttp://it is treated as an HTTP proxy. It overrides the proxy environment variables.-U,--proxy-useruser:password: the login for the proxy. The manual notes that curl hides the argument from process listings only partly, and that sensitive data should be read from a file instead and never used in clear text on a command line.--proxy-negotiate: HTTP Negotiate (SPNEGO) authentication with the proxy. For a proxy that signs people in with their Windows account, the manual describes, for a Windows SSPI-enabled curl,-U :to take the user name and password from the environment.--proxy-ntlm: NTLM authentication with the proxy. The manual states that NTLM support was removed in curl 8.24.0, and that the option then fails with an unsupported-feature error.--proxy-anyauth: let curl pick a suitable method, which may cost one extra round trip. Basic is curl's default for proxies.
To review pull requests behind a proxy: Pull Request Inbox for GitHub, a plugin for JetBrains IDEs 2024.1 or later, connects through the IDE's HTTP proxy settings, so one entry there covers it.
git
git's git-config manual says http.proxy overrides the proxy normally set by the http_proxy, https_proxy and all_proxy environment variables, in the form [protocol://][user[:password]@]proxyhost[:port][/path]. With a user name and no password, git tries to get the password the way it does for other credentials, so it asks for it instead of storing it.
git config --global http.proxy http://PROXY_USER@PROXY_HOST:PORT
Or for one session, in PowerShell:
$env:https_proxy = "http://PROXY_USER@PROXY_HOST:PORT"
- A password in the address is plain text: a password written as
user:password@in the configuration sits in a text file. git's own manual calls such a configured address "plaintext credentials" (intransfer.credentialsInUrl), and git-credential-store says the credentials it stores are unencrypted on disk, protected only by filesystem permissions. Leave the password out where you can. http.proxyAuthMethod: it takes effect only when the proxy string has a user name. The values areanyauth(the default: git assumes the proxy answers an unauthenticated request with 407 and lists its methods inProxy-Authenticate, and picks one),basic,digest(the password is not sent to the proxy in clear text),negotiateandntlm. TheGIT_HTTP_PROXY_AUTHMETHODenvironment variable overrides it.
GitHub CLI
The GitHub CLI manual's page on environment variables (gh help environment) does not list a proxy variable. In the GitHub CLI's issue tracker, a maintainer answers that gh goes through a proxy with HTTPS_PROXY (not HTTP_PROXY, because gh mostly makes HTTPS requests), and that the "https" in the name is about the requests being proxied, not about how the proxy itself is reached; another maintainer notes that Go supports HTTP_PROXY and NO_PROXY and that the manual should document them better (cli/cli#2037). The login goes in the same address:
$env:HTTPS_PROXY = "http://PROXY_USER:PROXY_PASSWORD@PROXY_HOST:PORT" gh auth status
In bash, export HTTPS_PROXY=... does the same. A password in an environment variable is visible to other programs started from that shell.
A JetBrains IDE
JetBrains' HTTP Proxy page: by default the IDE uses the system proxy settings. Under File | Settings | Appearance and Behavior | System Settings | HTTP Proxy (IntelliJ IDEA | Settings on macOS) choose Manual proxy configuration, then HTTP, fill Host name and Port number, tick Proxy authentication, and enter Login and Password. Remember keeps the password between sessions; without it, the IDE asks each time it first connects. Check Connection tests a URL through the proxy, https://api.github.com/zen for example.
What not to do
- Do not turn off certificate checks to get past an error. A proxy that opens HTTPS traffic uses its own certificate; the company's root certificate belongs in the trust store instead (see GitHub Enterprise Server not reached, which covers certificates).
- A 407 is not a bad token. If the proxy accepts you and GitHub answers 401, see 401 "Bad credentials".
GitHub pull requests in IntelliJ IDEA
Pull Request Inbox for GitHub, a plugin by Lesstep for JetBrains IDEs 2024.1 or later, connects through the IDE's HTTP proxy settings. When the proxy asks for a login and does not accept one, it says "The proxy asked for a login and did not accept one. Check Settings | Appearance & Behavior | System Settings | HTTP Proxy." The review inbox across repositories, diffs, viewed marks, conversations, merge checks and checks are free; approving, commenting and merging are Pro (US$1.50 a month, with a 30-day trial).
Get it on JetBrains Marketplace
GitHub is a trademark of GitHub, Inc.; IntelliJ IDEA is a trademark of JetBrains s.r.o. This page is not affiliated with or endorsed by GitHub, Inc. or JetBrains.
More: GitHub Enterprise Server not reached · GitHub API request timed out · GitHub 401 "Bad credentials" · GitHub 404 "Not Found" · Connect to GitHub over SSH · GitHub token permissions for pull requests · 日本語