Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.discovr.media/llms.txt

Use this file to discover all available pages before exploring further.

Use the web sign-in flow for web apps, mobile web apps, and any platform with a browser. User sees a login popup (or redirects to login), enters credentials, and returns to your app with a refresh token.

Getting started

1

Initialize client

Create a DiscovrClient with your client ID (from your dashboard or contact support).
2

Call sign-in

Use signInWithPopup() (popup) or signInWithWebAuth() (redirect). Handle the result.
3

Verify sign-in

Check if isSignedIn() is true. SDK stores refresh token securely.
4

Select a profile

Call getProfiles(), let user pick one, then selectProfile() with the chosen profile id. This mints a session token.
5

Ready to call API

Use DiscovrClient methods like createPage(), getRows(). SDK injects session token automatically.

Code example

import { DiscovrClient } from "discovr";

const client = new DiscovrClient("your-client-id", {
	basePath: "https://api.discovr.media",
});

// Sign in with popup (web) or redirect
await client.signInWithPopup();

// List profiles and pick one
const { profiles } = await client.getProfiles();
await client.selectProfile(profiles[0].id);

// Ready to call API
const page = await client.createPage();
console.log("Session active, page created:", page.id);

How it works

Web sign-in flow — popup or redirect, exchange for refresh token, select profile
Step by step:
  1. Your app calls signInWithPopup() or signInWithWebAuth()
  2. Discovr opens login UI (popup in browser or redirect)
  3. User enters email/password and authenticates
  4. Discovr returns to your app with authorization
  5. SDK exchanges authorization for refresh token
  6. Refresh token stored securely (Keychain, EncryptedSharedPreferences, or HttpOnly cookie depending on platform)
SDK stores refresh token securely and refreshes your session token every 30 minutes automatically. You don’t touch either token.
Use popups for better UX in web apps. Use redirects for mobile apps built with frameworks like React Native or Flutter.

Handling sign-in errors

try {
	await client.signInWithPopup();
} catch (err) {
	if (err.code === "USER_CANCELLED") {
		console.log("User closed login window");
	} else if (err.code === "NETWORK_ERROR") {
		console.log("Network error. Retry or check connection.");
	} else {
		console.log("Sign-in failed:", err.message);
		// Show user: "Sign-in failed. Try again."
	}
}
Common cases:
  • User cancels: User closes popup or goes back. Handle gracefully.
  • Network error: No internet or timeout. Show retry button.
  • Invalid credentials: User enters wrong email/password. SDK shows Discovr login UI, let user retry.
Never put refresh tokens in URLs or logs. SDK handles this for you.

Advanced: Manual HTTP implementation

If building a custom client without the SDK, handle the OAuth flow manually: signInWithPopup · signInWithWebAuth · getProfiles · selectProfile · createPage · getRows
Next: Select a profile and understand sessions