Skip to content

Commit 8b3d8ad

Browse files
committed
#83 fix gist_auth
httr::oauth2.0_token doesnt return token in header slot anymore change how token is accessed add at return for the fxn to tell users what should be returned bump dev version add news item
1 parent f214d09 commit 8b3d8ad

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

Diff for: DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Description: Work with 'GitHub' 'gists' from 'R' (e.g.,
1010
'gist' 'commits', and get rate limit information when 'authenticated'. Some
1111
requests require authentication and some do not. 'Gists' website:
1212
<https://gist.github.com/>.
13-
Version: 0.9.0.91
13+
Version: 0.9.0.93
1414
Authors@R: c(
1515
person("Scott", "Chamberlain", role = c("aut", "cre"),
1616
email = "[email protected]",

Diff for: NEWS.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
gistr in development
2+
===============
3+
4+
### BUG FIXES
5+
6+
* fix `gist_auth()`: at some point `httr::oauth2.0_token` stopped returning the token in the `headers` slot; can't figure out when this change happened; fix is to get the token from a different place in the returned object; changes to `gist_auth()` to access that new path to the token (#83)
7+
8+
19
gistr 0.9.0
210
===============
311

Diff for: R/gist_auth.R

+7-4
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,21 @@
1919
#' @param app An [httr::oauth_app()] for GitHub. The default uses an
2020
#' application `gistr_oauth` created by Scott Chamberlain.
2121
#' @param reauth (logical) Force re-authorization?
22+
#' @return a named list, with a single slot for `Authorization`, with a single
23+
#' element with the token - this is the expected format needed when passed
24+
#' down to the http request
2225
#' @examples \dontrun{
2326
#' gist_auth()
2427
#' }
2528

2629
gist_auth <- function(app = gistr_app, reauth = FALSE) {
2730

2831
if (exists("auth_config", envir = cache) && !reauth) {
29-
return(undo(cache$auth_config$headers))
32+
return(auth_header(cache$auth_config$auth_token$credentials$access_token))
3033
}
3134
pat <- Sys.getenv("GITHUB_PAT", "")
3235
if (!identical(pat, "")) {
33-
auth_config <- httr::add_headers(Authorization = paste0("token ", pat))
36+
auth_config <- list(auth_token=list(credentials=list(access_token=pat)))
3437
} else if (!interactive()) {
3538
stop("In non-interactive environments, please set GITHUB_PAT env to a GitHub",
3639
" access token (https://help.github.com/articles/creating-an-access-token-for-command-line-use)",
@@ -41,10 +44,10 @@ gist_auth <- function(app = gistr_app, reauth = FALSE) {
4144
auth_config <- httr::config(token = token)
4245
}
4346
cache$auth_config <- auth_config
44-
undo(auth_config$headers)
47+
auth_header(auth_config$auth_token$credentials$access_token)
4548
}
4649

47-
undo <- function(x) unclass(as.list(unclass(x)))
50+
auth_header <- function(x) list(Authorization = paste0("token ", x))
4851

4952
cache <- new.env(parent = emptyenv())
5053

Diff for: man/gist_auth.Rd

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)