refreshAccessToken(scope = null) {
    const clientId = this.getClientId();
    const clientSecret = this.getClientSecret();

    if (!clientId) {
      throw new Error('A client id is required. You can set the client id using .setClientId().');
    }
    if (scope && !(scope instanceof Array)) {
      throw new Error('Scope must be an array of strings');
    }

    let refreshUrl = OAuth2TokenUrl(this.domain, this.domainDelimiter);
    const fetchOptions = {
      headers: { 'Content-Type': 'application/json' },
      method: 'POST',
    };

    if (this.dataOnBody) {
      const body = { grant_type: 'refresh_token', client_id: clientId, refresh_token: this.getRefreshToken() };

      if (clientSecret) {
        body.client_secret = clientSecret;
      }
      if (scope) {
        body.scope = scope.join(' ');
      }

      fetchOptions.body = body;
    } else {
      refreshUrl += `?grant_type=refresh_token&refresh_token=${this.getRefreshToken()}`;
      refreshUrl += `&client_id=${clientId}`;
      if (clientSecret) {
        refreshUrl += `&client_secret=${clientSecret}`;
      }
      if (scope) {
        refreshUrl += `&scope=${scope.join(' ')}`;
      }
    }

    return this.fetch(refreshUrl, fetchOptions)
      .then((res) => parseResponse(res))
      .then((res) => {
        this.setAccessToken(res.result.access_token);
        this.setAccessTokenExpiresAt(getTokenExpiresAtDate(res.result.expires_in));
      });
  }
Refreshes the access token using the refresh token, if available
@arg {Array<String>} scope - a subset of scopes from the original
refresh to acquire with an access token
@returns {Promise<*>}