Skip to content

Commit e9e49ce

Browse files
authored
Add github token auth (#2481)
1 parent 039d103 commit e9e49ce

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

docs/scripts/update-contributors.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,17 @@ async function fetchUserInfo(username, retryCount = 0) {
243243
throw new Error(`Hit max retries (${MAX_RETRIES}) for fetching user ${username}`);
244244
}
245245

246-
const res = await fetch(`https://api.github.com/users/${username}`, {
246+
const request = new Request(`https://api.github.com/users/${username}`, {
247247
headers: {
248248
Accept: "application/vnd.github+json",
249249
"X-GitHub-Api-Version": "2022-11-28",
250250
},
251251
});
252+
if (process.env.GITHUB_TOKEN) {
253+
request.headers.set("Authorization", `Bearer ${process.env.GITHUB_TOKEN}`);
254+
}
255+
256+
const res = await fetch(request);
252257

253258
if (!res.ok) {
254259
const retryAfter = res.headers.get("retry-after"); // seconds

0 commit comments

Comments
 (0)