Skip to content

Commit ca5ab32

Browse files
authored
Fix missing auth token in list_sources() call (#3)
1 parent b5577a5 commit ca5ab32

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

R/sources.R

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,14 @@ ppm_get_source_id <- function(source_name, url) {
2323
#' @return A data.frame of source names and ids
2424
#' @export
2525
list_sources <- function(url = ppm_url()) {
26-
r <- jsonlite::fromJSON(construct_api_url("sources", url = url))
27-
merge(r$Sources, source_types, by.x = "type", by.y = "id")[,c("id", "name", "typename", "lang", "last_sync")]
26+
ppm_api_token <- getOption("ppm.api_token")
27+
r <- httr::GET(
28+
construct_api_url("sources", url = url),
29+
httr::add_headers(Authorization = paste("Bearer", ppm_api_token, sep=" "))
30+
)
31+
httr::stop_for_status(r)
32+
df <- jsonlite::fromJSON(httr::content(r, "text"))
33+
merge(df$Sources, source_types, by.x = "type", by.y = "id")[,c("id", "name", "typename", "lang", "last_sync")]
2834
}
2935

3036
source_types <- data.frame(
@@ -43,3 +49,4 @@ source_types <- data.frame(
4349
),
4450
lang = c("R", "R", "R", "R", "Python", "BioC", "R", "BioC", "Python", "Python", "Python")
4551
)
52+

0 commit comments

Comments
 (0)