- Published on
Resolving GitHub Action 401 Bad Credentials Error
- Authors
- Name
- hwahyeon
I encountered the following error in GitHub Action:
github.GithubException.BadCredentialsException: 401 {"message": "Bad credentials", "documentation_url": "https://docs.github.com/rest", "status": "401"}
Error: Process completed with exit code 1.
As the message github.GithubException.BadCredentialsException: 401 {"message": "Bad credentials"}
indicates, this means the authentication token used when making a request to the GitHub API is incorrect. A 401 status code indicates that the authentication credentials are invalid, and it can happen for the following reasons:
Incorrect GitHub access token
The provided token might be invalid or expired. You should create a new Personal Access Token on GitHub and ensure it has the necessary permissions (such as repo
access).
Token without proper access rights
The token might not have the necessary permissions to access the repository. Make sure that the personal access token has the appropriate permissions to access the specific repository. If the token was created as a personal token, explicit permission to access organizational or personal repositories may need to be granted.
GitHub access token not set or not passed through environment variables
The token might not be correctly configured in the GitHub Actions secrets
. Go to GitHub Settings > Developer settings > Personal access tokens, generate a new token with the required permissions, and register it in the secrets
.
In my case, the token had expired, and I resolved the issue by generating a new one.