Getting transient auth issues on Github Actions #187460
Replies: 4 comments
-
|
💬 Your Product Feedback Has Been Submitted 🎉 Thank you for taking the time to share your insights with us! Your feedback is invaluable as we build a better GitHub experience for all our users. Here's what you can expect moving forward ⏩
Where to look to see what's shipping 👀
What you can do in the meantime 💻
As a member of the GitHub community, your participation is essential. While we can't promise that every suggestion will be implemented, we want to emphasize that your feedback is instrumental in guiding our decisions and priorities. Thank you once again for your contribution to making GitHub even better! We're grateful for your ongoing support and collaboration in shaping the future of our platform. ⭐ |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
A 401 Unauthorized error using the default GITHUB_TOKEN (especially one that works intermittently) is usually tied to Race Conditions or Token Permissions in complex workflows like Merge Queues. Since your URL contains gh-readonly-queue, this is specifically related to GitHub Merge Queues. When a PR is in the queue, GitHub creates a temporary "shadow" ref to test the merge, and the standard token sometimes struggles to keep up with the rapid creation/deletion of these refs. Why this happens (The "Flaky 401") Permissions Lockdown: By default, GITHUB_TOKEN permissions are often set to "Read-only." In a Merge Queue, the runner might need explicit contents: read or metadata: read to query the API for that specific temporary branch. The Fixes
YAML Add metadata if you are querying repo-level informationmetadata: read Go to Settings > Actions > General. Under Workflow permissions, ensure "Read and write permissions" is selected, or at least that "Read" is guaranteed.
Create a Fine-grained PAT with "Contents" read access to that repository. Store it as a Secret (e.g., GH_API_TOKEN). Update your step to use that secret instead of the default token: YAML
Why it worked after re-runs |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for your answer @anshG2003 , sadly this is not related specifically to Merge Queue. In the picture above actions/checkout failed for a PR check. We never needed to set a PAT token before. It should work with the default Github Token. |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
-
Why are you starting this discussion?
Bug
What GitHub Actions topic or product is this about?
Actions Checkout
Discussion Details
Getting 401 using github.token. Worked after a few re-runs.
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://api.github.com/repos/ORG/REPO/commits/refs/heads/gh-readonly-queue/master/pr-1234-abc123
Beta Was this translation helpful? Give feedback.
All reactions