Learn R Programming

imguR (version 1.0.0)

imgur_login: Login to Imgur

Description

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

Usage

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.

Value

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.

Examples

Run this code
# 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

Run the code above in your browser using DataLab