Rename demo OAuthBrowserflowHttr2 to adjectiveCollocates

Change-Id: I7deabb293aee474850f20d6757a5306ef6c4d789
diff --git a/demo/00Index b/demo/00Index
index 9ea1d4a..3e9fbf2 100644
--- a/demo/00Index
+++ b/demo/00Index
@@ -13,5 +13,5 @@
 frequency_by_country_ggplot     Plot frequencies depending on country of publication using ggplot2.
 frequency_by_country_highcharts Plot frequencies depending on country of publication using highcharter.
 collocation_score_by_country    Plot collocation scores depending on country of publication using ggplot2.
-pluralGenderVariants            Plot frequencies of the plular gender variants of a word in the core corpus of the Council for German Orthography (OKK) over time.
-OAuthBrowserflowHttr2           Runtime OAuth2 browser flow demonstration using the httr2 package (adjective collocates of »Gendern«)
+pluralGenderVariants            Plot frequencies of the plural gender variants of a word in the core corpus of the Council for German Orthography (OKK) over time.
+adjectiveCollocates             Runtime OAuth2 browser flow demonstration using the httr2 package showing adjective collocates of 'Gendern'
diff --git a/demo/OAuthBrowserflowHttr2.R b/demo/OAuthBrowserflowHttr2.R
deleted file mode 100644
index b67564e..0000000
--- a/demo/OAuthBrowserflowHttr2.R
+++ /dev/null
@@ -1,14 +0,0 @@
-library(RKorAPClient)
-library(httr2)
-library(kableExtra)
-
-token <- oauth_client( id = "773NHGM76N7P9b6rLfmpM4",
-    token_url = "https://korap.ids-mannheim.de/api/v1.0/oauth2/token") %>%
-  oauth_flow_auth_code( scope = "search match_info",
-    auth_url = "https://korap.ids-mannheim.de/settings/oauth/authorize")
-
-new("KorAPConnection", verbose = TRUE, accessToken = token$access_token) %>%
-  collocationAnalysis("focus([marmot/p=ADJA] {Gendern})", leftContextSize=1, rightContextSize=0) %>%
-  mutate(collocate = paste0('<a href="', webUIRequestUrl, '">', collocate, '</a>')) %>%
-  select(collocate, O, pmi, mi2, mi3, logDice, ll) %>%
-  kable(escape = FALSE, caption = "Adjective collocates of 'Gendern'") %>% kable_styling()
diff --git a/demo/adjectiveCollocates.R b/demo/adjectiveCollocates.R
new file mode 100644
index 0000000..4ef8fa9
--- /dev/null
+++ b/demo/adjectiveCollocates.R
@@ -0,0 +1,32 @@
+library(RKorAPClient)
+library(httr2)
+library(kableExtra)
+
+demo_kor_app_id = "773NHGM76N7P9b6rLfmpM4"
+
+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
+  }
+  print(kco@accessToken)
+  return(kco)
+}
+
+new("KorAPConnection", verbose = TRUE) %>%
+  oauthorizeDemo() %>%
+  collocationAnalysis("focus([marmot/p=ADJA] {Gendern})", leftContextSize=1, rightContextSize=0) %>%
+  mutate(collocate = paste0('<a href="', webUIRequestUrl, '">', collocate, '</a>')) %>%
+  select(collocate, O, pmi, mi2, mi3, logDice, ll) %>%
+  kable(escape = FALSE, caption = "Adjective collocates of 'Gendern'") %>%
+  kable_styling() %>%
+  print()
+