store_creds: Store user credentials

Description Usage Token registration Setting a user agent Environment variables Examples

View source: R/store_creds.R

Description

store_creds prompts you for a Newsriver API token and user agent and permanently stores them so they are available for every R session.

store_creds_temp prompts you for a Newsriver API token and user agent and temporarily stores them so they are available for only the current R session.

Usage

1
2
3

Token registration

To register for an API token, visit the Newsriver site and follow the sign up procedures. Registration is free.

Setting a user agent

The user agent is a string used to identify the client. This allows Newsriver to identify who is using the API (and is important if something goes wrong). A good default user agent is your email address. Note: the user agent you supply does not need to be wrapped in quotes (nor does the API token).

Environment variables

Both store_creds and store_creds_temp store the supplied API token and user agent as environment variables called "NEWSRIVER_API_KEY" and "NEWSRIVER_USER_AGENT" respectively. These environment variables are then called by other newsrivr functions.

To store these environment variables, store_creds tries to find a .Renviron file located in your home directory. If no .Renviron file can be found, one will be created. Warning: only call store_creds once to prevent multiple environment variables being stored.

If you do not want to alter your global .Renviron file, then use store_creds_temp which stores environment variables for only the current R session. Alternatively an API token and user agent can be passed as arguments directly into the relevant newsrivr functions. This method is not recommended as credentials can accidentally get leaked in scripts and .Rhistory files.

Examples

1
2
3
4
5
6
## Not run: 
store_creds() # you will be prompted to enter your credentials

store_creds_temp() # you will be prompted to enter your credentials

## End(Not run)

MikeJohnPage/newsrivr documentation built on Jan. 4, 2021, 7:48 p.m.