spierce7
spierce7

Reputation: 15746

How to Create and Delete Personal Access Token's with the Github API?

I have a github bot with a personal access token that some github actions use to make commits during some action runs. I'd like to make a script that can automatically swap out this personal access token, and delete the old one via a cron job. Is this possible with the github API? If it's not possible, is there another mechanism I should be using instead perhaps?

Upvotes: 0

Views: 1690

Answers (1)

VonC
VonC

Reputation: 1324258

No, not for personal access token, whose API is deprecated, and removed in Nov. 2020.

You could try instead an installation access token for an app, which does have an API for creation.

By default the installation token has access to all repositories that the installation can access.
To restrict the access to specific repositories, you can provide the repository_ids when creating the token. When you omit repository_ids, the response does not contain the repositories key.

But that token, valid only one hour from the time you create them, might not have access to the same kind of action a PAT would have.

Upvotes: 1

Related Questions