async handleCallback()

in packages/oauth-client/src/OAuthClient.ts [134:153]


  async handleCallback() {
    if (isCallbackFromIframe()) {
      notifyParentFromIframe();
      return;
    }

    const url = new URL(window.location.href);

    const handshakeState = await this.#getHandshakeState();
    if (!handshakeState) {
      throw new Error('handshake state not found');
    }

    const grant = getGrantFromCallbackUrl(url, handshakeState);

    await this.#requestAndStoreToken(grant);
    await this.#deleteHandshakeState();

    window.location.href = handshakeState.originalUrl;
  }