Closed tanho63 closed 2 years ago
@tanho63 I'm open to more discussion as to whether we stop_for_status or warn_for_status. The former could be more of a nuisance in large batch runs, forcing users to work around with tryCatch or equivalent, but may indeed be the most reasonable behavior by default.
I had initially thought stop_for_status()
was better, but I re-read the contents of the prev issue and apparently it still returns the correct content sometimes despite the 401 error? (This seems doubtful, I wonder if it wasn't being checked properly...)
I think it's misleading when something gets written to the destination file that isn't
the correct contents, but if it sometimes works I guess I don't want to break it? That said if I was writing this from scratch I'd definitely use stop instead of warn. Happy to defer to whatever you think best
I identified the problem in #76 and #77 as related to https://github.com/ropensci/piggyback/blob/master/R/pb_download.R#L126 -
gh::gh_token()
returns""
if no environment variable or token is found, which creates anadd_headers(Authorization = paste("token", "")
call, causing a bad credentials/401 error.