Recently, I set up WSL2 and Ubuntu on my Windows 11 to work on some open-source projects. Since I also maintain these projects, I installed GitHub CLI to ease my workflow. I successfully installed the GitHub CLI, but failed to authenticate it.
The error message failed to authenticate via web browser: Too many requests have been made in the same timeframe. (slow_down)
appeared on my terminal, while on the web browser, it indicated that the authentication was successful.
I googled and found some workarounds that I tried, but only one worked like a charm!
After finally solving the tricky authentication issue for GitHub CLI on WSL2, I've put together this guide. It's a complete walkthrough for a solution that works, covering everything from a smooth installation to ongoing management.
Table of Contents
Prerequisites
Before getting started, ensure that you have these installed on your Windows machine:
WSL2
A Linux distro
Windows PowerShell
Windows Terminal (optional)
To follow the instructions in this article, you can use Windows PowerShell terminal as an administrator.
Alternatively, if you have Windows Terminal installed, you can use the Linux terminal by clicking the ‘down arrow’ icon at the top and selecting the distro.
How to Install GitHub CLI on WSL2
You can use the installation process described here if you use Ubuntu, Debian, or Raspberry Pi OS (apt) distros. For other distros other than those mentioned here, you can walk through the installation process that's available on the GitHub CLI official docs.
To install GitHub CLI in WSL2:
Run this command:
(type -p wget >/dev/null || (sudo apt update && sudo apt install wget -y)) \ && sudo mkdir -p -m 755 /etc/apt/keyrings \ && out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg \ && cat $out | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \ && sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \ && sudo mkdir -p -m 755 /etc/apt/sources.list.d \ && echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \ && sudo apt update \ && sudo apt install gh -y
Type your Linux password when you get prompted.
Ensure the GitHub CLI is installed by running
gh --version
command. If the installation is successful, you should see something like this in your terminal:gh version 2.76.2 (2025-07-30) https://github.com/cli/cli/releases/tag/v2.76.2
How to Authenticate GitHub CLI on WSL2 with Your GitHub Account
Before you can use GitHub CLI, you must first authenticate it. You will get an HTTP 401: Bad credentials (https://api.github.com/graphql)
error message if you run any GitHub CLI command without authenticating.
To authenticate GitHub CLI with your GitHub account:
Run the
gh auth login
command in your terminal.You will receive several prompts, and you need to choose the methods you prefer. Here’s what I selected in each prompt:
? Where do you use GitHub? GitHub.com ? What is your preferred protocol for Git operations on this host? HTTPS ? How would you like to authenticate GitHub CLI? Login with a web browser
After answering all prompts, you should get the message to copy a one-time code as shown below. You don’t need to copy the code at this point.
! First copy your one-time code: XXXX—XXXX
Press ‘Enter’. It automatically opens the "Device Activation" page on your browser.
Click the green ‘Continue’ button.
GitHub should ask you to enter the code displayed on your terminal, as shown in the screenshot below. But here’s the trick! Don’t paste any code, and don’t close the browser. Let’s first get back to your terminal.
Now you might get this error message on your terminal:
grep: /proc/sys/fs/binfmt_misc/WSLInterop: No such file or directory WSL Interopability is disabled. Please enable it before using WSL. grep: /proc/sys/fs/binfmt_misc/WSLInterop: No such file or directory [error] WSL Interoperability is disabled. Please enable it before using WSL.
Press
Ctrl + C
to stop the process if it's still running, or let it stop by itself. Once it's stopped, you should see this message:failed to authenticate via web browser: Too many requests have been made in the same timeframe. (slow_down)
Run the
gh auth login
command again and repeat the process to select the methods of your choice. This time, when it asks you to press ‘Enter’, don’t press it.Copy the latest code and return to the "Device Activation" page that you left open in your browser.
Paste the code that you copied and click the green ‘Continue’ button.
Click the green ‘Authorize github’ button after GitHub redirects you to the “Authorize GitHub CLI” page. You should now see the message “Congratulations, you're all set!”
Get back to your terminal and press ‘Enter’. Doing so triggers these actions:
It automatically opens a new “Device Activation” page in your browser. You can safely ignore this.
In the terminal, you first see the error message as in step 4. Don’t do anything and wait for a little bit. Then, you get:
✓ Authentication complete. - gh config set -h github.com git_protocol https ✓ Configured git protocol ! Authentication credentials saved in plain text ✓ Logged in as YOUR-GITHUB-USERNAME ! You were already logged in to this account
And GitHub CLI is now successfully authenticated!
Credit goes to username “ikeyan” on GitHub for their GitHub CLI authentication solution!
How to Upgrade GitHub CLI on WSL2
It’s always a good practice to regularly check for package and dependency updates, and upgrade to the newest version when it’s available — this includes GitHub CLI. To check for updates and upgrade the version of GitHub CLI:
Run the
sudo apt update
command in your terminal. This command fetches the list of available updates.Type your Linux password when you get prompted.
If you need to upgrade your GitHub CLI, run
sudo apt install gh
. This command installs the newest version of GitHub CLI.Type your Linux password when you get prompted.
Now your GitHub CLI has the newest version.
How to Uninstall GitHub CLI on WSL2
If one day you feel like you don’t need to use GitHub CLI anymore, you can uninstall it by following these steps:
Run the
sudo apt remove gh
command in your terminal.Type your Linux password when you get prompted.
Press ‘Y’ to continue the uninstall process.
GitHub CLI is now uninstalled from your WSL environment.
How to Revoke GitHub CLI Access on GitHub
After uninstalling the GitHub CLI, you might think your account access is gone, but it's not. The authentication you granted is still active. If you don't plan on using the CLI again, it's a good practice to revoke this access.
Here's how to do it directly from your GitHub account:
On your GitHub account, click your profile picture on the top right and click ‘Settings’.
On the left side bar, find ‘Integrations’ and click ‘Applications’.
Click the ‘Authorized OAuth Apps’ tab on top.
Find GitHub CLI and click the ‘three dots’ icon next to it.
Click ‘Revoke’.
Confirm it by clicking the ‘I understand, revoke access’ button.
Now, GitHub CLI doesn’t have access to your GitHub account.
Final Words
🖼️ Credit cover image: undraw.co
Thank you for reading! Last, you can find me on X and LinkedIn. Let's connect! 😊