Client ID assigned to your application on https://developer.audiotool.com/applications
Redirect URL after the user presses "Allow" on the consent screen. Must be registered for your application on https://developer.audiotool.com/applications
The scopes your app requires (e.g., "project:write"). Must be a subset of scopes assigned to your app.
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()
}
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.