Skip to content

Refactor R client functions for upload requests to include keycloak token #59

@doulikecookiedough

Description

@doulikecookiedough

To upload data to the vegbank API, users will be required to provide a valid token via keycloak authentication

We also need to provide a path for users to retrieve a valid token - one path we may leverage or build upon is how DataONE currently implements their authentication with R: by having users login via the DataONE search webapp, which provides the token for copy and paste directly into the R client like such:

options(dataone_token = "eyJhbGciOiJSUzI1NiJ9.eyJzdWIiOiJodHRwOlwvXC9vcmNpZC5vcmdcLzAwMDAtMDAwMy0wMDc3...TsnayXOS_PbaFSJ-iowSpX-Q")

DataONE then reads the token from the R options, and we may consider an alternative function like such:

vegbank::set_oidc_token(access, refresh=NULL)
  • Note 1: We may want to investigate the usage of oidc as it may be a bit wonky, see Matt's comment below:

metamattj: Or maybe oidc is a bit wonky and this should be named set_token or set_access_token or set_credentials or something more user understandable? I also remembered that we used keyring to securely store keys in the scythe package and it worked well -- might be better than a home-grown credentials store. See https://keyring.r-lib.org/

  • Note 2: We currently use httr2 under the hood for vegbankr, which may be useful for what we need, see Jim's comment below:

Jim: I just came across this and haven't really read it yet, but it might be useful: https://httr2.r-lib.org/articles/oauth.html
Note that the vegbankr package is already using httr2 under the hoo
metamattj: There are two big reasons to allow httr2 to manage tokens for you. The first is that httr2 will automatically refresh the token if it’s expired.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions