authorization {SC2API} | R Documentation |
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 |
verbose |
If verbose is set to TRUE, your access token will be printed on screen. |
Note
Access tokens expire after 24 hours.
References
Examples
## 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")
## End(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")
# Remove token from environment variable
unset_token()