async _handleOAuthFlow()

in src/nodes/server/hf-hub-login.ts [98:120]


  async _handleOAuthFlow() {
    const oauthResultStorage = localStorage.getItem("oauth");
    if (oauthResultStorage) {
      try {
        this.oauthResult = JSON.parse(oauthResultStorage);
      } catch {
        this.oauthResult = undefined;
      }
    }

    this.oauthResult ||= await this.oauthHandleRedirectIfPresent();

    if (this.oauthResult && typeof this.oauthResult === "object") {
      localStorage.setItem("oauth", JSON.stringify(this.oauthResult));
      this.dispatchEvent(
        new CustomEvent("outputs", {
          detail: { _apikey: this.oauthResult.accessToken },
        })
      );
    } else {
      this.buttonvisible = true;
    }
  }