From 2e7efef395b39722c788760360c02dbf23ece907 Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Thu, 31 Oct 2024 12:27:21 -0400 Subject: [PATCH 1/3] Work with dev httr2 `req$policies$auth_oauth$cache$clear()` is an internal which you shouldn't really be calling, but it seems like something generally useful so I made an new function for y'all. --- R/osmapiR_connection.R | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/R/osmapiR_connection.R b/R/osmapiR_connection.R index 9acd80c..acbaa10 100644 --- a/R/osmapiR_connection.R +++ b/R/osmapiR_connection.R @@ -158,9 +158,18 @@ authenticate_osmapi <- function() { #' @rdname authenticate_osmapiR #' @export logout_osmapi <- function() { - req <- httr2::request(base_url = get_osmapi_url()) - req <- oauth_request(req) - req$policies$auth_oauth$cache$clear() + + if (packageVersion("httr2") >= "1.0.5.9000") { + httr2::oauth_cache_clear( + client = oauth_client_osmapi(), + cache_disk = getOption("osmapir.cache_authentication"), + cache_key = getOption("osmapir.base_api_url") + ) + } else { + req <- httr2::request(base_url = get_osmapi_url()) + req <- oauth_request(req) + req$policies$auth_oauth$cache$clear() + } message("Logged out from ", get_osmapi_url()) From d323028c60425c9b081a64c44bb4a38d5d5b12b2 Mon Sep 17 00:00:00 2001 From: Hadley Wickham Date: Thu, 31 Oct 2024 12:36:47 -0400 Subject: [PATCH 2/3] Quiet R CMD check notes/warnings --- R/osmapiR_connection.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/R/osmapiR_connection.R b/R/osmapiR_connection.R index acbaa10..16df06c 100644 --- a/R/osmapiR_connection.R +++ b/R/osmapiR_connection.R @@ -159,8 +159,8 @@ authenticate_osmapi <- function() { #' @export logout_osmapi <- function() { - if (packageVersion("httr2") >= "1.0.5.9000") { - httr2::oauth_cache_clear( + if (utils::packageVersion("httr2") >= "1.0.5.9000") { + getFromNamespace("oauth_cache_clear", "httr2")( client = oauth_client_osmapi(), cache_disk = getOption("osmapir.cache_authentication"), cache_key = getOption("osmapir.base_api_url") From 171b8bcfec19c3c83ac07e6029eba4df38e0ee19 Mon Sep 17 00:00:00 2001 From: Joan Maspons Date: Tue, 12 Nov 2024 08:40:06 +0100 Subject: [PATCH 3/3] Use the new function `httr2::oauth_cache_clear()` from httr2 release 1.0.6 --- DESCRIPTION | 2 +- NEWS.md | 2 ++ R/osmapiR_connection.R | 17 +++++------------ 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 5ee1d34..e54feb2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -19,7 +19,7 @@ URL: https://docs.ropensci.org/osmapiR/, BugReports: https://github.com/ropensci/osmapiR/issues Imports: curl, - httr2, + httr2 (>= 1.0.6), xml2 Suggests: httptest2, diff --git a/NEWS.md b/NEWS.md index 682cfbd..42bc72d 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,7 @@ # osmapiR (development version) +* Use the new function `httr2::oauth_cache_clear()` from httr2 1.0.6 (#58 by @hadley). + # osmapiR 0.2.1 * Update CITATION with the JOSS article (). diff --git a/R/osmapiR_connection.R b/R/osmapiR_connection.R index 16df06c..61bda87 100644 --- a/R/osmapiR_connection.R +++ b/R/osmapiR_connection.R @@ -158,18 +158,11 @@ authenticate_osmapi <- function() { #' @rdname authenticate_osmapiR #' @export logout_osmapi <- function() { - - if (utils::packageVersion("httr2") >= "1.0.5.9000") { - getFromNamespace("oauth_cache_clear", "httr2")( - client = oauth_client_osmapi(), - cache_disk = getOption("osmapir.cache_authentication"), - cache_key = getOption("osmapir.base_api_url") - ) - } else { - req <- httr2::request(base_url = get_osmapi_url()) - req <- oauth_request(req) - req$policies$auth_oauth$cache$clear() - } + httr2::oauth_cache_clear( + client = oauth_client_osmapi(), + cache_disk = getOption("osmapir.cache_authentication"), + cache_key = getOption("osmapir.base_api_url") + ) message("Logged out from ", get_osmapi_url())