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.
All the documents are about to login github from website, and manually generate it.
Are there any automation way?
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 thisR
package: https://usethis.r-lib.org/reference/github-token.html