2

I am looking for the command or SDK, such as python, to generate new personal access token (PAT) in Github, but I didn't see any API for it.

https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token

All the documents are about to login github from website, and manually generate it.

Are there any automation way?

Bill
  • 2,494
  • 5
  • 26
  • 61

1 Answers1

4

Unfortunately, this isn't something that can be done completely programmatically. Creating PATs requires sudo mode on GitHub, which prompts the user to authenticate.

The best you can do is use a command to prefill parts of the creation of a PAT (scopes, description, etc.). This isn't currently a feature of any Python package, though something similar exists in this R package: https://usethis.r-lib.org/reference/github-token.html

ExplosiveFridge
  • 190
  • 1
  • 6