Skip to contents

Dryad also issues a client id/secret pair (from the same account settings page as the plain token in dryad_pat()), meant for the OAuth2 client-credentials grant. Unlike a plain token, which expires after 10 hours and must be regenerated by hand, a client id/secret is exchanged for a short-lived access token automatically – and refreshed automatically, for as long as the credentials themselves stay valid – every time a request needs one, via httr2::req_oauth_client_credentials(). This is the right choice for a long-running corpus build; dryad_pat() remains available for a single quick session where generating a client id/secret is not worth the extra step.

Usage

dryad_auth(
  client_id = NULL,
  client_secret = NULL,
  token_url = "https://datadryad.org/oauth/token"
)

Arguments

client_id

the OAuth2 client id, or NULL to get the current client

client_secret

the OAuth2 client secret, required when client_id is supplied

token_url

the token endpoint; Dryad's documented default should not normally need overriding

Value

invisibly, the httr2::oauth_client() built from the current credentials, or NULL when none are set

Details

Store client_id/client_secret as the DRYAD_CLIENT_ID/ DRYAD_CLIENT_SECRET environment variables so they are read every time R starts, the same way dryad_pat() reads DRYAD_PAT.

Examples

if (FALSE) { # \dontrun{
dryad_auth("my-client-id", "my-client-secret")
} # }