Skip to main content
This walks through a full login. A user approves your app, your app receives a token, and your app reads the profile of the user who approved access.

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

Build an authorize URL and redirect the user to it. The SDK generates the PKCE values for you. Keep code_verifier and state for the callback.
login.ts
The user lands on the consent screen, sees the scopes you asked for, and approves. We then redirect back to your redirect_uri with a short lived code and the state you sent.

Handle the callback

Verify the state, 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.