How to authenticate using GitHub Auth

Hi everybody! Today I will guide you through setting up and using GitHub CLI to authenticate to GitHub. This procedure uses a Personal Access Token that is a special password you can use to login to GitHub instead of your actual account password. It is more secure than the usual login password but to be frank not as secure and convenient as authentication through SSH. The first step is to have the github cli tool in your computer. I presently have ArchLinux, so I enter the following command to install it. You can use the package manager on your system to install it on your system. yay -S github-cli Once this is done, you will have to go over to the GitHub website and create a personal access token. Go to settings on your GitHub profile. Click Developer Settings on the left sidebar. On the left select and click Classic Personal Access Token. Then, click on Generate new token(classic). You can write a note for your reference. And check repo, workflow and admin:org scopes. You can also provide an expiration date if required. That's it the token is generated. Save it in a safe place as it will not be accessible later. Now, we have to access a folder in VS Code. Go to the terminal, and type gh auth login Select GitHub.com. Then, on the next prompt select HTTPS. Next, the computer will ask to authenticate using GitHub credentials. Select yes. Finally, select the option to paste an authentication token and paste it in the required prompt. That's it you are now logged in through your own created Personal Access Token, and this process is way more secure. It is also suitable to be employed by beginner developers.

Apr 10, 2025 - 18:10
 0
How to authenticate using GitHub Auth

Hi everybody! Today I will guide you through setting up and using GitHub CLI to authenticate to GitHub. This procedure uses a Personal Access Token that is a special password you can use to login to GitHub instead of your actual account password. It is more secure than the usual login password but to be frank not as secure and convenient as authentication through SSH.
The first step is to have the github cli tool in your computer. I presently have ArchLinux, so I enter the following command to install it. You can use the package manager on your system to install it on your system.
yay -S github-cli
Once this is done, you will have to go over to the GitHub website and create a personal access token.

  1. Go to settings on your GitHub profile.
  2. Click Developer Settings on the left sidebar.
  3. On the left select and click Classic Personal Access Token.
  4. Then, click on Generate new token(classic).
  5. You can write a note for your reference. And check repo, workflow and admin:org scopes. You can also provide an expiration date if required. That's it the token is generated. Save it in a safe place as it will not be accessible later.

Now, we have to access a folder in VS Code. Go to the terminal, and type gh auth login
Image description

Select GitHub.com.
terminal view showing step-by-step process of login using gh auth login command of github cli tool

Then, on the next prompt select HTTPS.
terminal view showing step-by-step process of login using gh auth login command of github cli tool

Next, the computer will ask to authenticate using GitHub credentials. Select yes.
terminal view showing step-by-step process of login using gh auth login command of github cli tool

Finally, select the option to paste an authentication token and paste it in the required prompt.
terminal view showing step-by-step process of login using gh auth login command of github cli tool
terminal view showing step-by-step process of login using gh auth login command of github cli tool
terminal view showing step-by-step process of login using gh auth login command of github cli tool

That's it you are now logged in through your own created Personal Access Token, and this process is way more secure. It is also suitable to be employed by beginner developers.