imgur_login: Login to Imgur

Description Usage Arguments Details Value Author(s) Examples

View source: R/imgur_login.r

Description

Complete an interactive login to Imgur to generate an OAuth2.0 token

Usage

1
2
3
imgur_login(client_id = "1babd0decbb90f2",
            secret = "06eed15f8e3662c20d7ff95a62853266400aae5a",
            cache = TRUE)

Arguments

client_id

A graphics device function. Default is png.

secret

Name of the file to be uploaded to imgur.com

cache

A logical indicating whether to cache the OAuth2.0 token for use later on. If TRUE, OAuth2.0 token is automatically cached in a file called “.httr-oauth” in the working directory.

Details

Most operations in the package can be performed anonymously using the default package API key. In order to perform most account-specific operations it is necessary to use OAuth authentication, which can only be performed interactively via a web browser. imgur_login returns an OAuth2.0 reference class object that can be passed as the token argument to all other functions in the package.

The OAuth token is moderately long lived; the response object contains a timestamp indicating its expiration time. The token can be subsequently refreshed using the refresh() method.

If cache = TRUE, the OAuth2.0 token is automatically cached in a file called “.httr-oauth” in the working directory. This token will then be loaded automatically the next time imgur_login is called (even in a new R session). To override an existing cache, set cache = FALSE.

Value

An OAuth2.0 reference class object, returned by oauth2.0_token.

Author(s)

Thomas J. Leeper

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
## Not run: 
# login interactively
tkn <- imgur_login()
# use token in the `imgur` device
i <- imgur('png', token = tkn)
hist(rnorm(20))
imgur_off(i)

# reload previous token
rm(tkn)
# OAuth token is automatically stored by 
# `imgur_login` if `cache = TRUE` (the default)
# It is reloaded by calling `imgur_login`
tkn <- imgur_login()
token$refresh() # refresh token

## End(Not run)

imguR documentation built on May 2, 2019, 4:02 p.m.