Adapt demos to simplified authorization
Change-Id: If29075378f77cc8872cbf59c3e3d92fe39b84fb6
diff --git a/demo/pluralGenderVariants.R b/demo/pluralGenderVariants.R
index 8ff8c3b..ef9d310 100644
--- a/demo/pluralGenderVariants.R
+++ b/demo/pluralGenderVariants.R
@@ -1,10 +1,6 @@
library(RKorAPClient)
library(tidyverse)
library(purrrlyr)
-library(httr2)
-library(httpuv)
-
-demo_kor_app_id = "773NHGM76N7P9b6rLfmpM4"
# The challenge in searching gender variants with KorAP and DeReKo is that,
# firstly, some characters used for gender marking, especially punctuation marks,
@@ -47,29 +43,13 @@
}
}
-oauthorizeDemo <- function(kco, app_id = demo_kor_app_id) {
- if (is.null(kco@accessToken) || is.null(kco@welcome)) { # if access token is not set or invalid
- kco@accessToken <- ( # request one
- oauth_client(
- id = app_id, # for the demo application
- token_url = paste0(kco@apiUrl, "oauth2/token")
- ) %>%
- oauth_flow_auth_code(
- scope = "search match_info",
- auth_url = paste0(kco@KorAPUrl, "settings/oauth/authorize")
- )
- )$access_token
- }
- kco
-}
-
plotPluralGenderVariants <- function(word = "Nutzer",
years = c(1995:2022),
as.alternatives = FALSE,
vc = "referTo ratskorpus-2023-1 & pubDate in",
suffixes = c('Innen', '[\\*]innen"', '[_]innen"', ' innen'),
prefixes = c('', '"', '"', ''),
- kco = new("KorAPConnection", verbose=TRUE) %>% oauthorizeDemo()) {
+ kco = new("KorAPConnection", verbose=TRUE) %>% auth()) {
hc <-
frequencyQuery(kco, paste0(prefixes, word, suffixes), paste(vc, years), as.alternatives=as.alternatives) %>%
unravelPunctuationGenderCases(kco = kco) %>%