Unable to create a Personal Access Token via API #148626
-
Select Topic AreaGeneral BodyHi Everyone, I am currently working on a project that requires regular rotation of GitHub Personal Access Tokens, with the goal of creating a new token and deleting the old one every month. While developing this solution, I couldn’t find any documentation or API endpoints in GitHub’s resources that support creating Personal Access Tokens programmatically. Can you please confirm whether this functionality is still supported? If not, is there a better/recommended approach for automating token rotation within GitHub? Note: I am aiming for the Token (Classic) version to be created and deleted via REST API endpoint in python. Thank you for your assistance! Thank you |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Automating GitHub Personal Access Token RotationHi Akshay, GitHub currently does not support programmatic creation or deletion of Personal Access Tokens (PATs), including the classic tokens, via their REST or GraphQL APIs. Personal Access Tokens must be created manually through the GitHub settings page. Recommended Approaches for Automating Token Rotation
Alternatives to Classic Tokens:GitHub is encouraging the use of fine-grained Personal Access Tokens, which offer better security controls and will eventually replace classic tokens. While these still cannot be created programmatically, they may better suit your use case. Next Steps:
I hope this helps! Let me know if you need further clarification. Best regards, |
Beta Was this translation helpful? Give feedback.
-
Thank you @rajtilak-2020 , that helped |
Beta Was this translation helpful? Give feedback.
Automating GitHub Personal Access Token Rotation
Hi Akshay,
GitHub currently does not support programmatic creation or deletion of Personal Access Tokens (PATs), including the classic tokens, via their REST or GraphQL APIs. Personal Access Tokens must be created manually through the GitHub settings page.
Recommended Approaches for Automating Token Rotation
Use GitHub Apps for Automation:
S…