Allow using GitHub access token or oauth to surpass api.github.com ratelimits
txtsd opened this issue · 6 comments
We've been getting 403 Rate Limit Exceeded on our builds, and this would be a great new feature.
@txtsd it's been a while since I've played w/ the GitHub API, but does it [still?] support setting the GITHUB_TOKEN as an env var, and would that work for you here?
@txtsd it's been a while since I've played w/ the GitHub API, but does it [still?] support setting the GITHUB_TOKEN as an env var, and would that work for you here?
That only works from within GitHub Actions, afaik.
Ah, I think I've mostly used the npm @octokit/rest package when playing w/ the GitHub API and could set my auth
token in there from an env var, per https://octokit.github.io/rest.js/v19#authentication.
Also found https://docs.github.com/en/rest/rate-limit which also recommends Octokit if you're using JavaScript.
https://www.11ty.dev/docs/plugins/fetch/#fetch-google-fonts-css has an example of passing custom HTTP headers. And the above rate limit link shows setting a custom bearer token in the cURL example: -H "Authorization: Bearer <YOUR-TOKEN>"\
. Wonder if a combination of that sorcery might work. 🤔
So this cURL will show your API rate limit status:
curl -L \
-H "Accept: application/vnd.github+json" \
https://api.github.com/rate_limit
{
"resources": {
...
},
"rate": {
"limit": 60,
"remaining": 52,
"reset": 1679368640,
"used": 8,
"resource": "core"
}
}
Now I guess the question is generating a GitHub auth token and trying to explicitly set the "Authorization: Bearer <YOUR-TOKEN>"
header and see if those authenticated requests count against your quota.
This is supported, example here:
Thank you.