Skip to content
This repository has been archived by the owner on Jun 2, 2023. It is now read-only.

Commit

Permalink
Merge pull request #11 from USGS-R/excise-dssecrets
Browse files Browse the repository at this point in the history
excise dssecrets
  • Loading branch information
jesse-ross authored Mar 30, 2023
2 parents 7612e4a + 656e183 commit 7970888
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/sb_utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ sb_replace_files <- function(sb_id, ..., file_hash){
if (!sbtools::is_logged_in()){

sb_secret <- dssecrets::get_dssecret("cidamanager-sb-srvc-acct")
message(paste("Using the secret dated", sb_secret$timeStamp, "to log in."))
sbtools::authenticate_sb(username = sb_secret$username, password = sb_secret$password)

}
Expand Down Expand Up @@ -128,8 +129,12 @@ do_item_replace_tasks <- function(sb_id, files, sources) {
upload_and_record <- function(sb_id, filepath) {

# First verify that you are logged into SB. Need to do this for each task that calls
sb_secret_login()

if (!sbtools::is_logged_in()) {
if (suppressWarnings(suppressMessages(require(dssecrets)))) {
message("ScienceBase is not logged in. Using dssecrets to log in with the cidamanager-sb-srvc-acct secret")
sb_secret_login()
}
}
# Second, upload the file
item_replace_files(sb_id, files = filepath)

Expand All @@ -153,7 +158,13 @@ upload_and_record <- function(sb_id, filepath) {
#' or if any duplicated file names exist on sciencebase for this `sb_id`.
verify_uploads <- function(file_tbl, tgt_names, remake_file){

sb_secret_login()
# First verify that you are logged into SB. Need to do this for each task that calls
if (!sbtools::is_logged_in()) {
if (suppressWarnings(suppressMessages(require(dssecrets)))) {
message("ScienceBase is not logged in. Using dssecrets to log in with the cidamanager-sb-srvc-acct secret")
sb_secret_login()
}
}
sb_id <- unique(file_tbl$sb_id)
# this call is not robust to a tbl w/ more than one unique sb_id
stopifnot(length(sb_id) == 1)
Expand Down

0 comments on commit 7970888

Please sign in to comment.