I am currently trying to run R scripts from Jenkins via the following plugin (https://plugins.jenkins.io/r/) all on an AWS EC2 instance
The problem now is that I can't authenticate myself in a non-interactive way as indicated by the gargle library documentation.
The gargle cache is well filled (here is the sitrep)
ℹ Taking cache location from the `"gargle_oauth_cache"` option.
1 token found in this gargle OAuth cache:
'~/.cache/gargle'
email app scopes hash...
________________ _______________ ________ __________
secret@secret.fr tidyverse-erato ...drive 928dfaa...
but the drive_auth method always returns the same error:
Error in `drive_auth()`:
! Can't get Google credentials
ℹ Are you running googledrive in a non-interactive session? Consider:
• `drive_deauth()` to prevent the attempt to get credentials
• Call `drive_auth()` directly with all necessary specifics
ℹ See gargle's "Non-interactive auth" vignette for more details:
ℹ <https://gargle.r-lib.org/articles/non-interactive-auth.html>
Backtrace:
▆
1. └─googledrive::drive_auth(...)
2. └─googledrive:::drive_abort(...)
3. └─cli::cli_abort(message = message, ..., .envir = .envir)
4. └─rlang::abort(...)
Execution halted
And so I can't download a remote file placed on my drive:
drive_download(as_id("id"), path = "~/sku.csv", overwrite = TRUE)
sku <- read_csv2("~/sku.csv", locale = locale(encoding = "CP1252"),
col_names = TRUE, col_types = NULL, guess_max = 20000)
print(sku)
my code:
#### R Library ####
library(utils)
library(dplyr)
library(rlang)
library(tidyr)
library(stringr)
library(lubridate)
library(gargle)
library(googledrive)
library(readr)
library(DBI)
library(httr)
library(cronR)
library(RPostgreSQL) # Connect PostgreSQL db
options(encoding = "CP1252")
Sys.setenv(TZ="CET")
default_locale()
## Settings for Google Drive connexion
options(gargle_verbosity = "debug")
options(gargle_oauth_cache = "~/.cache/gargle")
options(httr_oob_default = TRUE)
gargle_oauth_sitrep()
print(gargle_verbosity())
print(sessionInfo())
drive_auth(email = "secret@secret.com",
scopes = "https://www.googleapis.com/auth/drive",
use_oob = TRUE,
cache = "~/.cache/gargle") # mettre cache = FALSE si on souhaite generer un nouveau token
print(drive_user())
# From Drive
#### From cloud
### Products & co.
## Import
# Sku
drive_download(as_id(id), path = "~/sku.csv", overwrite = TRUE)
sku <- read_csv2("~/sku.csv", locale = locale(encoding = "CP1252"),
#col_names = TRUE, col_types = NULL, guess_max = 20000)
print(sku)
# Permet de reinitialiser les recuperations d'hyperlien sur GOOGLE #
# suite a des updates pour eviter des erreurs #
I also tried to connect to the GUI of my instance in order to connect interactively to fill the cache for the first time and used the same token, but also without success.