Skip to content

Commit

Permalink
feat(app/action): throw for fine-grained PAT (see #1292)
Browse files Browse the repository at this point in the history
  • Loading branch information
lowlighter committed Dec 12, 2022
1 parent d5df4ff commit 3df41e5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion source/app/action/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}
Expand Down

0 comments on commit 3df41e5

Please sign in to comment.