You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Move redirectUri to SDK config (set once in sdk.ts)
- Replace loginAsync/getRedirectResult with login/handleRedirect
- Use hasRedirectResult() and isAuthenticated() as async methods
- Remove sdk.oauth null-checks (oauth is always defined)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: packages/web/examples/upload/README.md
+18-3Lines changed: 18 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,15 +4,30 @@ A serverless Audius track upload example using SDK + OAuth PKCE entirely in the
4
4
5
5
## How it works
6
6
7
-
1. User clicks "Sign in with Audius" — `sdk.oauth.loginAsync({ scope: 'write' })` opens a popup, runs the PKCE flow, and stores the access token internally in the SDK's `tokenStore`.
8
-
2. User picks an audio file (and optional cover art), fills in title/genre/description.
9
-
3. On upload:
7
+
1. User clicks "Sign in with Audius" — `sdk.oauth.login({ scope: 'write', display: 'popup' })` opens a popup and runs the PKCE flow. The `redirectUri` is set once in the SDK config (see `src/sdk.ts`).
8
+
2. The popup redirects to Audius, then back to `redirectUri` (this same app) with an authorization code in the URL.
9
+
3. On the callback page (inside the popup), `sdk.oauth.handleRedirect()` detects `window.opener`, forwards the authorization code back to the parent window via `postMessage`, and closes the popup.
10
+
4. The parent's `login()` promise resolves; call `sdk.oauth.getUser()` to retrieve the authenticated user's profile. The access token is stored internally in the SDK's `tokenStore`.
11
+
5. User picks an audio file (and optional cover art), fills in title/genre/description.
12
+
6. On upload:
10
13
-`sdk.uploads.createAudioUpload({ file })` uploads audio to a storage node → returns `trackCid`, `origFileCid`, `duration`, etc.
11
14
-`sdk.uploads.createImageUpload({ file })` uploads cover art → returns `coverArtSizes` CID.
12
15
-`sdk.tracks.createTrack({ userId, metadata })` registers the track on-chain, authenticated via the stored OAuth access token.
13
16
14
17
## Setup
15
18
19
+
### 1. Register the redirect URI
20
+
21
+
In your developer app settings at **audius.co/settings → Developer Apps**, add the following redirect URI:
22
+
23
+
```
24
+
http://localhost:5177
25
+
```
26
+
27
+
This is required so the OAuth server will accept the callback URL when the popup redirects back to this app. For production deployments, register your deployed URL instead (e.g. `https://yourapp.com`).
28
+
29
+
### 2. Configure and run
30
+
16
31
```bash
17
32
cp .env.example .env
18
33
# Edit .env and set VITE_AUDIUS_API_KEY to your developer app API key
0 commit comments