Skip to content

How to put the console inside your app

The console your app serves at {api_prefix}/_telltale/admin/ asks for a key. You can show it on an admin page of your own app instead, where your admins are already signed in.

  1. Let your admins into the telltale API with an authorize hook:

    def authorize(request):
    user = current_user(request)
    return "admin" if user and user.is_admin else None
    tt.authorize = authorize

    With this hook set, the API is mounted even when no key is set.

  2. Add the console to an admin page, with your app’s authenticated fetch:

    import { TelltaleConsole } from './vendor/telltale/react/TelltaleConsole.jsx'
    import './vendor/telltale/console/console.css'
    <TelltaleConsole apiBase="/api/_telltale" fetch={authedFetch} app="myapp" />

    Without React, call mountConsole(element, { apiBase, fetch, app }) from console/console.js.

  3. Match your app’s look. The console takes all its styles from --tt-* CSS variables on .tt-console:

    .tt-console {
    --tt-font-family: var(--app-font);
    --tt-accent: var(--app-primary);
    }

    The console README lists every variable.

  4. Check it. Signed in as an admin, the page shows the console with no key prompt. Signed in as anyone else, the API answers 401.