async getToken()

in packages/oauth-client/src/OAuthClient.ts [101:114]


  async getToken(): Promise<OAuthTokenState> {
    const token = await this.#tokenCache.getValue();

    if (!token) {
      // TODO: Handle this error better
      throw new Error('No token found! We need to do OAuth handshake again...');
    }

    if (!isValidToken(token, this.#owner)) {
      return this.#refreshToken(token);
    }

    return token;
  }