Skip to contents

Use osf_pat() to get the token used to authorise OSF API requests, or osf_pat("your-token") to set it for the rest of the session.

Usage

osf_pat(pat = NULL)

Arguments

pat

the token to set, or NULL to get the current token

Value

the current token (character; "" when none is set)

Details

Without a token you can make 100 API requests per hour; with one you can make 10,000 per day, so a token is worth setting before downloading whole projects or listing everything a user has.

To create one, sign in at https://osf.io/settings/tokens, click "Create token", give it a name, and tick the osf.full_read scope (add osf.full_write only if you also intend to write to the OSF). Copy the token immediately, as the OSF does not show it again.

The usual way to store it is a line in your .Renviron file (open it with usethis::edit_r_environ()), which is read every time R starts:

OSF_PAT="replace-with-your-token-string"

Setting the token with osf_pat() overrides that for the current session only, which is useful when you cannot edit .Renviron or want to use a different account for one run.

Examples

osf_pat() # returns "" unless a token is set
#> [1] ""