From 681aa89dcdeb45ec2f6705377cf00d35d15d5e6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Quiroz?= Date: Fri, 16 Dec 2022 16:47:01 -0300 Subject: [PATCH] chore: update gh api fetch --- src/utils/fetchLatestReleaseCommit.ts | 8 +++++++- src/utils/fetchLatestReleaseVersionAndName.ts | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/utils/fetchLatestReleaseCommit.ts b/src/utils/fetchLatestReleaseCommit.ts index 005abcbb33..b0d6612dc9 100644 --- a/src/utils/fetchLatestReleaseCommit.ts +++ b/src/utils/fetchLatestReleaseCommit.ts @@ -1,7 +1,13 @@ import { ALL_GETH_COMMITS_URL } from '../constants'; export const fetchLatestReleaseCommit = (versionNumber: string) => { - return fetch(`${ALL_GETH_COMMITS_URL}/${versionNumber}`) + const headers = new Headers({ + // Note: this token expires on Dec 16, 2023 + // check fine-grained tokens https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token#about-personal-access-tokens + Authorization: 'Token ' + process.env.GITHUB_TOKEN_READ_ONLY + }); + + return fetch(`${ALL_GETH_COMMITS_URL}/${versionNumber}`, { headers }) .then(response => response.json()) .then(commit => commit.sha.slice(0, 8)); }; diff --git a/src/utils/fetchLatestReleaseVersionAndName.ts b/src/utils/fetchLatestReleaseVersionAndName.ts index e022766067..1bc91ec568 100644 --- a/src/utils/fetchLatestReleaseVersionAndName.ts +++ b/src/utils/fetchLatestReleaseVersionAndName.ts @@ -1,7 +1,13 @@ import { LATEST_GETH_RELEASE_URL } from '../constants'; export const fetchLatestReleaseVersionAndName = () => { - return fetch(LATEST_GETH_RELEASE_URL) + const headers = new Headers({ + // Note: this token expires on Dec 16, 2023 + // check fine-grained tokens https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token#about-personal-access-tokens + Authorization: 'Token ' + process.env.GITHUB_TOKEN_READ_ONLY + }); + + return fetch(LATEST_GETH_RELEASE_URL, { headers }) .then(response => response.json()) .then(release => { return {