Learn R Programming

SC2API (version 1.0.0)

authorization: Authorization

Description

The Blizzard API uses OAuth 2.0 for authorization. For more information on how Blizzard uses OAuth in their API, visit https://develop.battle.net/documentation/guides/using-oauth.

Before using the Blizzard API, one must first create a client in the Blizzard Developer Portal and obtain a valid client ID and client secret. For more information on getting started, see: Getting Started.

Once a client has been created, use set_token and supply the client id and client secret as arguments to set an environment variable for all future API calls.

Once set_token() has been used, an access token can be removed from the environment using remove_token()

Note that access tokens are set to expire in 24 hours and, subsequently, a new token must be used for any future API calls.

Usage

set_token(client_id, client_secret, access_token, verbose = FALSE)

validate_token(access_token)

unset_token()

Arguments

client_id, client_secret

A client ID and client secret can be obtained from the Blizzard Developer Portal. For more information on creating a client, visit Getting Started.

access_token

An OAuth 2.0 access token required to use the Blizzard API. Access tokens can be obtained by using set_token with a valid client ID and client secret.

verbose

If verbose is set to TRUE, your access token will be printed on screen.

References

Examples

Run this code
# NOT RUN {
#Get and set a token as an environment variable
set_token(client_id = "YOUR CLIENT ID", client_secret = "YOUR CLIENT SECRET")

#Set an access token that you have already retrieved as an environment variable
set_token(access_token = "YOUR TOKEN")
# }
# NOT RUN {
# Ensure that a valid token is currently set as an environment variable
validate_token()
# Check if a token is valid
validate_token("TEST TOKEN")
# }
# NOT RUN {
# Remove token from environment variable
unset_token()
# }

Run the code above in your browser using DataLab