Skip to content

Commit

Permalink
Allow to download assets without GITHUB_PAT
Browse files Browse the repository at this point in the history
  • Loading branch information
hsonne committed Oct 23, 2023
1 parent 494884a commit 4909d4c
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions R/install_abimo.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,20 @@ download_assets <- function(
}

# Provide non-exported function github_pat() from package remotes
github_pat <- utils::getFromNamespace("github_pat", "remotes")
token <- utils::getFromNamespace("github_pat", "remotes")()

# Compose HTTP header (with or without token)
headers <- c(
if (!is.null(token)) c(Authorization = paste("token", token)),
Accept = accept
)

for (i in seq_len(nrow(asset_info))) {

utils::download.file(
url = asset_info$url[i],
destfile = file.path(destdir, asset_info$name[i]),
headers = c(
Authorization = paste("token", github_pat()),
Accept = accept
),
headers = headers,
mode = "wb"
)
}
Expand Down

0 comments on commit 4909d4c

Please sign in to comment.