GitHub provides two types of tokens for authentication: Classic Personal Access Tokens (PATs) and Fine-Grained Personal Access Tokens. This guide will focus on generating Fine-grained PATs as Github recommends this over the other since it provides better security.
In the upper-right corner of any page on GitHub, click your profile photo, then click Settings.
In the left sidebar, click Developer settings.
In the left sidebar, under Personal access tokens, click Fine-grained tokens.
Click Generate new token.
Under Token name, enter a name for the token.
Under Expiration, select an expiration for the token. Infinite lifetimes are allowed but may be blocked by a maximum lifetime policy set by your organization or enterprise owner.
Optionally, under Description, add a note to describe the purpose of the token
Under Resource owner, select a resource owner. The token will only be able to access resources owned by the selected resource owner.
Optionally, if the resource owner is an organization that requires approval for fine-grained personal access tokens, below the resource owner, in the box, enter a justification for the request.
Under Repository access, select which repositories you want the token to access.
If you selected Only select repositories in the previous step, under the Selected repositories dropdown, select the repositories that you want the token to access.
Under Permissions, select which permissions to grant the token.