From 2ce4774f5b8c49fbf4f44a0b819660b86979449c Mon Sep 17 00:00:00 2001 From: js2264 Date: Tue, 7 Nov 2023 12:23:52 +0100 Subject: [PATCH] feat: ensure repo/workflow/user:email scopes are enabled for github PAT in use --- R/init.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/R/init.R b/R/init.R index 68bfbf8..cfe5e32 100644 --- a/R/init.R +++ b/R/init.R @@ -152,10 +152,12 @@ init <- function( } ) gh_scopes <- gh::gh_whoami(.token = PAT)$scopes - for (scope in c("repo", "workflow", "user:email")) { + for (scope in c("repo", "workflow")) { if (!grepl(scope, gh_scopes)) cli::cli_abort("The provided PAT does not authorize the `{scope}` scope. Please change the PAT settings @ https://github.com/settings/tokens to enable this scope.\n") } + if (!grepl("user:email|user", gh_scopes)) + cli::cli_abort("The provided PAT does not authorize the `user:email` scope. Please change the PAT settings @ https://github.com/settings/tokens to enable this scope.\n") gh_user <- gh::gh_whoami(.token = PAT)$login cli::cli_alert_success(cli::col_grey("Successfully logged in Github")) cli::cli_ul(c(