Skip to main content

Install

Overview

@urantia/auth handles the OAuth Authorization Code flow with accounts.urantiahub.com. Users sign in once and authorize your app to access their data (bookmarks, notes, reading progress, preferences). Your app receives an access token (7-day expiry) that you pass to @urantia/api for authenticated endpoints.

Browser Sign-In (Redirect)

The most common flow for web apps:
1

Start sign-in

Redirect the user to accounts.urantiahub.com:
2

Handle the callback

On your redirect URI page, complete the flow:
3

Use the token

Pass the access token to @urantia/api:

Browser Sign-In (Popup)

For desktop apps or when you don’t want to navigate away:

Server-Side Token Exchange

For backend environments where you already have an authorization code and app secret:
Server-side exchange is more secure because the app secret never leaves your server. The demo app uses this approach — the browser handles the redirect, and a server-side API route exchanges the code.

Session Management

Sessions are automatically persisted in localStorage and restored on page load.

Available Scopes

When calling signIn(), you can request specific scopes:

Options

Security

  • PKCE (Proof Key for Code Exchange) — used automatically for browser flows to prevent authorization code interception
  • State parameter — CSRF protection via random state verification
  • Token expiry — access tokens expire after 7 days; expired sessions are automatically cleared
  • App secrets — never stored in the browser; use server-side token exchange for production apps

Registering Your App

To use @urantia/auth, you need a registered OAuth app.
1

Sign in to the Developer Portal

Go to accounts.urantiahub.com/apps and sign in with your Urantia account (email or Google).
2

Create a new app

Click Create app and fill in:
  • App ID — a unique slug (e.g. my-reading-app). Lowercase letters, numbers, and hyphens.
  • App Name — shown to users on the consent screen
  • Redirect URIs — URLs where users are sent after authorization (e.g. http://localhost:3000/callback for local dev)
  • Scopes — which permissions your app needs
3

Save your credentials

After creation, you’ll see your App ID and App Secret. The secret is only shown once — save it somewhere secure.
Your app secret is only displayed once. If you lose it, you can rotate it from the app details page, but any existing integrations using the old secret will break.
4

Start building

Use your App ID to initialize the SDK:
You can manage your apps, rotate secrets, and delete apps at any time from the Developer Portal.