AtOAuth
class AtOAuth(clientMetadataUrl: String, sessionStore: OAuthSessionStore, httpClient: HttpClient, json: Json = Json { ignoreUnknownKeys = true })
AT Protocol OAuth 2.0 flow orchestrator for public clients.
Implements the full authorization flow: handle → DID → PDS → authorization server discovery, PAR with PKCE + DPoP, browser-based authorization, token exchange, and session management with transparent refresh.
Consumer usage
val oauth = AtOAuth(
clientMetadataUrl = "https://app.example.com/oauth/client-metadata.json",
sessionStore = mySessionStore,
httpClient = myKtorClient,
)
// Step 1: get the authorization URL
val authUrl = oauth.beginLogin("alice.bsky.social")
// Step 2: open authUrl in a browser (Custom Tabs on Android)
// Step 3: capture the redirect URI
oauth.completeLogin(redirectUri)
// Step 4: use the authenticated client
val client = oauth.createClient()
FeedService(client).getTimeline()Content copied to clipboard
Constructors
Link copied to clipboard
constructor(clientMetadataUrl: String, sessionStore: OAuthSessionStore, httpClient: HttpClient, json: Json = Json { ignoreUnknownKeys = true })
Functions
Link copied to clipboard
Starts the OAuth login flow.
Link copied to clipboard
Completes the OAuth login flow after the browser redirects back.
Link copied to clipboard
Creates an authenticated XrpcClient from the persisted session. The client uses DpopAuthProvider for DPoP proof-of-possession on every request.