From 3df41e5a3eac5d682c43eec8143ea693a597af2c Mon Sep 17 00:00:00 2001 From: lowlighter <22963968+lowlighter@users.noreply.github.com> Date: Sun, 11 Dec 2022 21:59:56 -0500 Subject: [PATCH] feat(app/action): throw for fine-grained PAT (see #1292) --- source/app/action/index.mjs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/app/action/index.mjs b/source/app/action/index.mjs index 7912a01e..f85bb553 100644 --- a/source/app/action/index.mjs +++ b/source/app/action/index.mjs @@ -171,9 +171,11 @@ function quit(reason) { info("GitHub token", token, {token: true}) //A GitHub token should start with "gh" along an additional letter for type //See https://github.blog/2021-04-05-behind-githubs-new-authentication-token-formats - info("GitHub token format", /^gh[pousr]_/.test(token) ? "correct" : "(old or invalid)") + info("GitHub token format", /^github_pat_/.test(token) ? "fine-grained" : /^gh[pousr]_/.test(token) ? "classic" : "legacy or invalid") if (!token) throw new Error("You must provide a valid GitHub personal token to gather your metrics (see https://github.com/lowlighter/metrics/blob/master/.github/readme/partials/documentation/setup/action.md for more informations)") + if (/^github_pat_/.test(token)) + throw new Error("It seems you're trying to use a fine-grained personal access token. These are currently unsupported as GitHub does not support them (yet?) for GraphQL API authentication (see https://docs.github.com/fr/graphql/guides/forming-calls-with-graphql#authenticating-with-graphql for more informations). Use a classic token instead.") conf.settings.token = token const api = {} const resources = {}