Skip to content

Commit 28d1340

Browse files
committed
docs: update loopback docs
1 parent 8c3c2a1 commit 28d1340

1 file changed

Lines changed: 15 additions & 14 deletions

File tree

packages/sdk-core/README.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,27 +59,25 @@ For local development and testing, you can use HTTP loopback URLs with `localhos
5959
// lib/atproto.ts
6060
import { createATProtoSDK } from "@hypercerts-org/sdk-core";
6161

62+
const baseUrl = "http://127.0.0.1:3000";
63+
const scope = "atproto transition:generic";
64+
const redirectUri = `${baseUrl}/api/auth/callback`;
65+
6266
const sdk = createATProtoSDK({
6367
oauth: {
64-
// Use localhost for client_id (loopback client)
65-
clientId: "http://localhost/",
66-
67-
// Use 127.0.0.1 with your app's port for redirect
68-
redirectUri: "http://127.0.0.1:3000/api/auth/callback",
69-
70-
scope: "atproto",
71-
72-
// Serve JWKS from your app
73-
jwksUri: "http://127.0.0.1:3000/.well-known/jwks.json",
68+
// Client ID embeds all metadata as query parameters
69+
clientId: `http://localhost?scope=${encodeURIComponent(scope)}&redirect_uri=${encodeURIComponent(redirectUri)}`,
70+
// Redirect URI: MUST use 127.0.0.1 (not localhost)
71+
redirectUri,
72+
scope,
73+
// JWKS URI: same origin as redirect URI
74+
jwksUri: `${baseUrl}/jwks.json`,
7475

7576
// Load from environment variable
7677
jwkPrivate: process.env.ATPROTO_JWK_PRIVATE!,
77-
78-
// Optional: suppress warnings
79-
developmentMode: true,
8078
},
8179
// Optional: handle resolver for local testing
82-
handleResolver: "http://localhost:2583",
80+
handleResolver: "https://bsky.social",
8381
logger: console, // Enable debug logging
8482
});
8583

@@ -129,6 +127,9 @@ ATPROTO_JWK_PRIVATE='{"keys":[{"kty":"EC","crv":"P-256",...}]}'
129127

130128
### Important Notes
131129

130+
> **Embed scope and redirect in client_id**: For loopback clients, embed scope and redirect in client_id. Otherwise the
131+
> oauth complains about missing scope and redirect.
132+
132133
> **Authorization Server Support**: The AT Protocol OAuth spec makes loopback support **optional**. Most AT Protocol
133134
> servers support loopback clients for development, but verify your target authorization server supports this feature.
134135

0 commit comments

Comments
 (0)