Build an appConnection examples

Connection examples

Choose an OAuth example for your backend, native app, or browser client.

Start after creating your application. Each example uses the same R+D authorization-code flow with S256 PKCE and reads only the connected user's profile. Choose the platform you registered, not just your preferred language.

ExampleLanguagesWhat you get
Backend OAuthTypeScript on Node.js 24, Python 3.11+Framework-independent helpers for authorization, callbacks, API calls, refresh, and revocation
Native / desktopJavaScript on Node.js 24, Python 3.11+Runnable local demos using the system browser and an IP-loopback callback
Client-side browserJavaScript, TypeScriptA runnable HTML demo with a public client, registered origin, and in-memory access token

These examples use standard libraries and browser APIs. The backend helpers need your framework's authenticated session and storage adapter. The native and browser demos can be run after registering their callbacks and setting your own client ID. They are teaching examples, not an R+D SDK or a complete production application.

Silent recording of the local app with synthetic accounts. The interface is in English; captions are available in English, German, French, and Dutch.

This walkthrough uses a backend app and an accepted tester. It shows consent, a real code exchange, and revocation; it does not demonstrate an API data request. The same consent and disconnect steps apply to native and browser clients.

Download video (WebM)

The exchange all platforms share

  1. Create fresh random state and a PKCE verifier for this connection attempt. Retain them in the initiating user's session.
  2. Open your configured issuer's /oauth/authorize with response_type=code, client ID, callback, scope, state, and the S256 challenge.
  3. At the callback, consume the pending transaction once. Check state and iss before handling approval or denial.
  4. Send the code, the exact callback, and the verifier to /oauth/token using form encoding. Backend clients also authenticate with their registered secret method.
  5. Read the granted scope. Send Authorization: Bearer ... to the API only for features the user authorized.

Use one fixed issuer for each environment. Discover its endpoints through /.well-known/oauth-authorization-server; never choose a token endpoint from an unvalidated callback's iss. Staging and production registrations and tokens are separate. OAuth tokens are opaque and are not OpenID Connect ID tokens.

Errors to handle

ResultApp behavior
error=access_denied at callbackValidate state and issuer, consume the attempt, and return the user to an unconnected state
Unexpected state, issuer, duplicate callback parameters, or expired attemptReject the response without exchanging the code; start a new attempt
Token endpoint rejects the codeDo not reuse it; verify callback, PKCE, environment, and the registered client-authentication method
API 401Access may have expired or been revoked; refresh once if you have a valid refresh token, otherwise reconnect
API 403Check granted scopes and existing account/device permissions
API 429Wait for Retry-After before sending another request
Refresh timeout or an ambiguous responseDo not retry the old refresh token; reconnect if you cannot recover the stored replacement

Access tokens last ten minutes. The samples omit offline_access; the backend guide explains how to add it when needed. OAuth API traffic is limited to 60 requests per minute per app and user. See the protocol reference for the complete scope and token lifecycle rules.

On this page