View source: R/session_details.R
session_details | R Documentation |
Get the details associated with current ScienceBase user session.
session_details(..., session = current_session())
... |
Additional parameters are passed on to |
session |
SB session object from |
list, if not logged in states that, but if logged in, user details If logged in, will include a "jossoSessionId" that can be used for authenticated file downloads by appending josso='jossoSessionId' to the url for the file requiring authentication. This is helpful when passing a url to a library that will handle the download of a remote file automatically such as jsonlite::readJSON or readr::read_csv.
## Not run:
session_details()
# If logged in, can use jossoSessionId for downloads.
authenticate_sb()
temp_json <- tempfile(fileext = ".json")
jsonlite::write_json(list(test = "test"), temp_json)
item <- item_upload_create(sbtools::user_id(), temp_json)
token <- session_details()$jossoSessionId
(base_url <- item$file[[1]]$downloadUri)
# will fail
try(jsonlite::read_json(base_url))
url <- paste0(base_url, "&josso=", token)
jsonlite::read_json(url)
item_rm(item$id)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.