message: clock tolerance was being called in sample app before the client created
diff: -import { Issuer, TokenSet, custom, } from 'openid-client';
  +import { Issuer, TokenSet } from 'openid-client';
  import * as xero from './gen/api';
  import request = require('request');
  import http = require('http');
  @@ -37,17 +37,14 @@ export class XeroClient {
  client_secret: this.config.clientSecret,
  redirect_uris: this.config.redirectUris,
  });
  + this.openIdClient.CLOCK_TOLERANCE = 5; // to allow a 5 second skew in the openid-client validations
  }
  async buildConsentUrl() {
  - this.openIdClient[custom.clock_tolerance] = 5; // to allow a 5 second skew in the openid-client validations
  -
  - const url = this.openIdClient.authorizationUrl({
  + this.openIdClient.authorizationUrl({
  redirect_uri: this.config.redirectUris[0],
  scope: this.config.scopes.join(' ') || 'openid email profile'
  });
  -
  - return url;
  }
  async setAccessTokenFromRedirectUri(url: string) {
  @@ -73,7 +70,6 @@ export class XeroClient {
  }
  async refreshToken() {
  -
  if (!this.tokenSet) {
  throw new Error('tokenSet is not defined');
  }
  @@ -83,18 +79,7 @@ export class XeroClient {
  await this.fetchConnectedTenantIds();
  }
  - private setAccessTokenForAllApis() {
  - const accessToken = this.tokenSet.access_token;
  - if (typeof accessToken === 'undefined') {
  - throw new Error('Access token is undefined!');
  - }
  -
  - this.accountingApi.accessToken = accessToken;
  - // this.payrollApi.accessToken = accessToken;
  - // etc.
  - }
  -
  - private async fetchConnectedTenantIds() {
  + async fetchConnectedTenantIds() {
  // retrieve the authorized tenants from api.xero.com/connections
  const result = await new Promise<{ response: http.IncomingMessage; body: Array<{ id: string, tenantId: string, tenantType: string }> }>((resolve, reject) => {
  request({
  @@ -117,9 +102,22 @@ export class XeroClient {
  });
  });
  + result.body.map(connection => console.log('connection: ',connection));
  +
  this._tenantIds = result.body.map(connection => connection.tenantId);
  // Requests to the accounting api will look like this:
  // let apiResponse = await xeroClient.accountingApi.getInvoices(xeroClient.tenantIds[0]);
  }
  +
  + private setAccessTokenForAllApis() {
  + const accessToken = this.tokenSet.access_token;
  + if (typeof accessToken === 'undefined') {
  + throw new Error('Access token is undefined!');
  + }
  +
  + this.accountingApi.accessToken = accessToken;
  + // this.payrollApi.accessToken = accessToken;
  + // etc.
  + }
  }
  