From 0a6b4cbea58ef327b2cf463bfce0b3af4f7cb242 Mon Sep 17 00:00:00 2001
From: "Azadpour, Elmera" <eazadpour@usgs.gov>
Date: Thu, 3 Oct 2024 11:58:34 -0700
Subject: [PATCH] add sciencebase login steps

---
 README.md | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index e0d6252..3c5f923 100644
--- a/README.md
+++ b/README.md
@@ -16,7 +16,7 @@ This project:
 
 ## Running the targets pipeline in R
 
-Clone the repo. In RStudio, run `library(targets)` and `tar_make()`. This will require `tidycensus` credentialing to run, see instructions below.
+Clone the repo. In RStudio, run `library(targets)` and `tar_make()`. This will require `tidycensus` and `sciencebase` credentialing to run, see instructions below.
 
 
 ## `tidycensus` set up
@@ -36,6 +36,18 @@ census_api_key("YOUR API KEY GOES HERE", install = TRUE)
 readRenviron("~/.Renviron")
 ```
 
+## ScienceBase login
+To access controlled ScienceBase items, an additional step must be completed to authenticate a ScienceBase session before the targets pipeline is run.
+
+1.  Ensure `.gitignore` includes a line for ".Renviron" to prevent credentials from being committed the the repository by git.
+2.  Run the entire contents of `00_config.R` either (1) interactively (i.e., line by line) or (2) by running `source("00_config.R")`.
+3.  You will be prompted to enter the token text by R/Rstudio. A browser window should pop-up directing you to <https://sciencebase.usgs.gov/manager/> to login.
+4.  Once logged in, copy your API token: click the account drop down button (person shaped icon) and click **Copy API Token**.
+5.  Paste the API token into the RStudio popup.
+
+Once the above steps are complete, `initialize_and_cache_sb()` will cache your username and token into the .Renviron file. From here, the pipeline should be able to use those cached credentials to re-initialize and refresh ScienceBase sessions in different R sessions for up to 10 hours.
+
+
 ## Building the website locally
 
 Clone the repo. In the directory, run `npm install` to install the required modules. Once the dependencies have been installed, run `npm run dev` to run locally from your browser.
-- 
GitLab