Skip to content

GitHub API error #2

@jrosen48

Description

@jrosen48

When I run the following code in the github_repos chunk:

s_ghn <- safely(gh_next) # API calls are fraught with peril, so make this one a bit safer

my_repos_file <- file.path(rt, "data", "my_repos.rds")

if (!file.exists(my_repos_file)) {
  curr_repo <- gh("/user/repos", username = "public")
  my_repos <- list()
  i <- 1
  my_repos[i] <- list(curr_repo)
  spin <-  TRUE
  while(spin) {
    curr_repo <- s_ghn(curr_repo)
    if (is.null(curr_repo$result)) break
    i <- i + 1
    curr_repo <- curr_repo$result
    my_repos[i] <- list(curr_repo)
  }
  my_repos <- unlist(my_repos, recursive=FALSE)
  write_rds(my_repos, my_repos_file)
} else {
  my_repos <- read_rds(my_repos_file)
}

The following error is returned:

Error in gh("/user/repos", username = "public") : 
  GitHub API error (401): 401 Unauthorized
  Requires authentication

I checked on a few ways to authenticate but could not find out how to authenticate with GitHub. Is there a separate step (through GitHub - or locally) that needs to be done before running this?

Thank you for sharing this awesome resource!

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions