@audiotool/nexus - v0.0.17
    Preparing search index...

    Function audiotool

    • Initialize Audiotool in the browser with OAuth2 authentication.

      This is the main entry point for browser applications. It handles the OAuth2 PKCE flow, including redirects to the consent screen and token management.

      When authenticated, the returned object IS the client - you can call API methods directly on it.

      Parameters

      • __namedParameters: { clientId: string; redirectUrl: string; scope: string }

      Returns Promise<BrowserAuthResult>

      import { audiotool } from "@audiotool/nexus"

      const at = await audiotool({
      clientId: "your-client-id",
      redirectUrl: "http://127.0.0.1:5173/",
      scope: "project:write",
      })

      if (at.status === "authenticated") {
      const projects = await at.projects.listProjects({})
      console.log(`Hello, ${at.userName}!`)

      // To use on server, export tokens
      const tokens = at.exportTokens()
      await fetch("/api/store-session", { body: JSON.stringify(tokens) })
      }

      if (at.status === "unauthenticated") {
      if (at.error) {
      console.error("Auth failed:", at.error)
      }
      // Show login button
      button.onclick = () => at.login()
      }