# 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: 5/24/2021, 10:47:35 PM