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: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 inlocalStorage and restored on page load.
Available Scopes
When callingsignIn(), you can request specific scopes:
| Scope | Access |
|---|---|
profile | Read your profile information |
bookmarks | Read and write bookmarks |
notes | Read and write notes |
reading-progress | Read and write reading progress |
preferences | Read and write preferences |
app-data | Read and write your app data |
Options
| Option | Type | Required | Default |
|---|---|---|---|
appId | string | Yes | — |
appSecret | string | Server only | — |
redirectUri | string | Browser | — |
loginUrl | string | No | https://accounts.urantiahub.com |
apiUrl | string | No | https://api.urantia.dev |
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.
Sign in to the Developer Portal
Go to accounts.urantiahub.com/apps and sign in with your Urantia account (email or Google).
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/callbackfor local dev) - Scopes — which permissions your app needs
Save your credentials
After creation, you’ll see your App ID and App Secret. The secret is only shown once — save it somewhere secure.
You can manage your apps, rotate secrets, and delete apps at any time from the Developer Portal.