Release automatic callback setup in SDK 0.2.0
Hop-State: A_06FPARPGMNVEAN3XBVH0QD8 Hop-Proposal: R_06FPARNXMP3DGP5VQGGX4Z8 Hop-Task: T_06FPAR9KH2V5ED7V65JEN00 Hop-Attempt: AT_06FPAR9KH3NZ1CV8RGPJDSG
This commit is contained in:
@@ -24,16 +24,19 @@ import {
|
||||
const stuffbox = new StuffboxClient({ baseUrl: "https://stuffbox.xyz" });
|
||||
const pkce = await createPkcePair();
|
||||
const state = generateState();
|
||||
const savedClientId = await loadStuffboxClientId();
|
||||
|
||||
const connection = await stuffbox.createConnectionRequest({
|
||||
selfHosted: true,
|
||||
...(savedClientId ? { clientId: savedClientId } : {}),
|
||||
callbackUrl: "https://yourapp.example/api/stuffbox/callback",
|
||||
codeChallenge: pkce.challenge,
|
||||
scopes: ["assets:read"],
|
||||
state,
|
||||
});
|
||||
|
||||
// Persist all four values before redirecting the user's browser.
|
||||
// No dashboard registration is needed. Persist the returned identity and
|
||||
// pending PKCE state before redirecting the user's browser.
|
||||
await saveStuffboxClientId(connection.clientId);
|
||||
await savePendingConnection({
|
||||
clientId: connection.clientId,
|
||||
callbackUrl: connection.callbackUrl,
|
||||
@@ -57,7 +60,7 @@ const tokens = await stuffbox.exchangeAuthorizationCode({
|
||||
});
|
||||
```
|
||||
|
||||
Hosted applications register once in the Stuffbox developer dashboard and send their assigned `clientId` instead of `selfHosted: true`. A first-time self-hosted installation receives a stable public client ID automatically; persist it for later connections.
|
||||
Stuffbox creates or reuses an identity for the exact callback automatically. Pass the returned `clientId` on later connections when available. The client ID is public routing information, not a secret.
|
||||
|
||||
## Read a user's media library
|
||||
|
||||
|
||||
Reference in New Issue
Block a user