Prerequisites
1
Register a Web application
Create a Web application in the console and add a redirect URI, for example
https://your.app/callback. See Register an application.2
Grant the profile scope
Add the
profile:read scope so your app can read the user’s account.3
Install the SDK
Send the user to the consent page
Build an authorize URL and redirect the user to it. The SDK generates the PKCE values for you. Keepcode_verifier and state for the callback.
login.ts
redirect_uri with a short lived code and the state you sent.
Handle the callback
Verify thestate, then exchange the code for tokens. exchange_code returns a ready to
use client that acts as the user.
callback.ts
nemu.user.get() returns the user who approved access. This is the answer to “who clicked
Authorize”.Keep the session
exchange_code accepts an on_refresh callback so you can persist rotated tokens. Restore a
client later with from_tokens.
Next steps
Authorization code
The raw HTTP behind the SDK, including PKCE and error handling.
Scopes
Everything you can request beyond the profile.