-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0-get-token.R
22 lines (16 loc) · 958 Bytes
/
0-get-token.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# načíst či vytvořit autorizační soubor
if (file.exists('token.rds')) {
url <- readRDS('token.rds') # gitignored file :)
} else {
url <- paste0('https://ckc-emea.cisco.com/corev4/token/?client_secret=',
rstudioapi::showPrompt(title = "Client Secret", message = "Client Secret", default = ""),
'&client_id=',
rstudioapi::showPrompt(title = "Client ID", message = "Client ID", default = ""),
'&grant_type=password&username=',
rstudioapi::showPrompt(title = "Username", message = "Username (incl. @prague-city.com)", default = "@prague-city.com"),
'&password=',
rstudioapi::showPrompt(title = "Password", message = "Password", default = ""))
saveRDS(url, 'token.rds') # uložit ještě před otestováním
}
response <- POST(url)
if (response$status_code != 200) file.remove('token.rds') # když nefunguje, tak smazat...