get_token: Generate an access token for the Reddit API

Description Usage Arguments Details Value Examples

Description

Generate an access token for the Reddit API

Usage

1
2
3
4
5
6
7
8
get_token(
  scope = c("identity", "read", "history", "wikiread"),
  useragent,
  username = NULL,
  password = NULL,
  client_id = NULL,
  client_secret = NULL
)

Arguments

scope

The scope of what you want to access. Must be one of these: identity, read, history, wikiread

useragent

The useragent for the device accessing the API

username

Username for the Reddit profile accessing the API. If left empty, it will attempt to read from the environment. Can be set with Sys.setenv(REDDIT_API_USERNAME = "")

password

Password for the Reddit profile accessing the API. If left empty, it will attempt to read from the environment. Can be set with Sys.setenv(REDDIT_API_PASSWORD = "")

client_id

The id of the app through which the API is accessed.If left empty, it will attempt to read from the environment. Can be set with Sys.setenv(REDDIT_API_CLIENT_ID = "")

client_secret

The client secret of the app through which the API is accessed. If left empty, it will attempt to read from the environment. Can be set with Sys.setenv(REDDIT_API_SECRET = "")

Details

Access tokens are recquired to acccess any of the endpoints of the API. Access tokens are only valid for an hour. It is recquired to define an App through which the API is being accessed. Apps can be defined in the settings at this page https://www.reddit.com/prefs/apps/. Client ID and Client Secret must be taken from this page. More info about accessing the API at https://www.reddit.com/dev/api/

More info at https://www.reddit.com/dev/api/

Value

A list containing the access token, the time until it expires, the scope, the time it was generated and the useragent

A list containing the access token, its scope, the acces time and the useragent.

Examples

1
2
3
4
5
6
7
8
9
## Not run: 
read_token <- get_token(scope = "read",
                        useragent = useragent,
                        username = username,
                        password = password,
                        client_id = client_id,
                        client_secret = client_secret)

## End(Not run)

jfeldhege/redditoR documentation built on April 2, 2020, 9:42 p.m.