A beginner guide on Using GitHub Tokens with Android Studio

What is GitHub Token?

This is a security feature by GitHub which allows you to set rules on how different apps will interact with your repositories.

In July, we announced our intent to require the use of token-based authentication (for example, a personal access, OAuth, or GitHub App installation token) for all authenticated Git operations. Beginning August 13, 2021, we will no longer accept account passwords when authenticating Git operations on GitHub.com.
Read more about GitHub tokens

If you have tried setting up GitHub on your Android Studio you might have been prompted to use tokens instead of passwords. Screenshot from 2021-04-10 00-01-56.png

However,when you login using your details,you will get this error Screenshot from 2021-04-10 00-16-43.png and if by chance you setup successfully using username and password you are likely to receive this email

Screenshot from 2021-04-09 23-43-31.png

Setting up GitHub tokens

Enabling 2FA

Unfortunately,for you to be able to setup tokens you have to enable 2FA. So first enable then continue from here. Use this link incase you don't know how to enable Set 2Fa .

Use either an auth app or a phone number as your recovery options. An auth app is mostly preffered since GitHub does not support phone numbers in some countries,one of them being my country Kenya.

Screenshot from 2021-04-09 23-48-02.png

Now let's get to setting up tokens

Since GitHub already have a detailed documentation on how to create a personal tokens let me not copy paste, just follow this link Creating personal access tokens and create one. Don't forget to save your token in a safe place because once you are done setting up it will disappear.

Now go back to Android studio and set up GitHub

On the dialog screen,click on use tokens and you will be taken to this screen. Screenshot from 2021-04-10 00-57-43.png

Paste your token then login.

Congrats and thanks for following to this far.