This function authenticates you into Bangumi. The documentation for the Bangumi API provides more details including alternate methods if you desire to reimplement your own.

bgm_auth(
  new_user = FALSE,
  key = "bgm2725b1fa2fea5582",
  secret = "b84bdc8fcc3c68dd277a6b9650f33867",
  cache = TRUE,
  rdstoken = NA
)

Arguments

new_user

Set to TRUE if you need to switch to a new user account or just flush existing token. Default is FALSE.

key

Your application key (ID). bangumir already comes with a key/secret but you are welcome to swap out with our own. Since these keys are shipped with the package, there is a small chance they could be voided if someone abuses the key. If you plan to use this in production, or for an internal tool, the recommended practice is to create a new application on Bangumi and use those keys for your purposes.

secret

Your application secret. Like key, bangumir comes with a secret but you are welcome to swap out with our own.

cache

By default your credentials are locally cached in a file called .httr-oauth. Set to FALSE if you need to authenticate separately each time.

rdstoken

File path to stored RDS token. In server environments where interactive OAuth is not possible, a token can be created on a desktop client and used in production. See examples.

Value

A Token2.0 object, invisibly

References

API documentation

Examples

if (FALSE) { # To either read token from .httr-oauth in the working directory or open a # web browser to authenticate (and cache a token) bgm_auth() # If you want to overwrite an existing local token and switch to a new # user, set new_user to TRUE. bgm_auth(new_user = TRUE) # To store a token for re-use (more flexible than .httr-oauth), save the # output of bgm_auth and save it to an RDS file token <- bgm_auth() saveRDS(token, "/path/to/tokenfile.RDS") # To use a stored token provide token location bgm_auth(rdstoken = "/path/to/tokenfile.RDS") }