For Github
To generate Github repository token, Login to Github, Click on Settings > Go to Developer Settings.
On the left hand side select Personal Access Tokens and Click Generate new token button.
Select the options as below and click on Generate Token.

For Gitea
To generate Gitea repository token, Login to Gitea, Click on Settings > Go to Applications

Provide the name for the Token and Click on Generate Token button.