# Getting access token

BlizzAPI exposes getAccessToken method which returns a promise of access token as a string.

Example with promises:

const BlizzAPI = require('blizzapi');

const BnetApi = new BlizzAPI({ 'us', 'client id', 'client secret' });

BnetApi.getAccessToken()
  .then((accessToken) => {
    // do something with accessToken
  });

Example with async / await:

const BlizzAPI = require('blizzapi');

const BnetApi = new BlizzAPI({{ 'us', 'client id', 'client secret' });
const accessToken = await BnetApi.getAccessToken();

// do something with accessToken
Last Updated: 7/31/2019, 5:13:56 PM