{% extends "root.html" %}
{% block inner %}
<div class="space-y-6 text-left">
<h2 class="text-2xl font-bold text-accent">API tokens</h2>
<p class="text-sm opacity-70">
Long-lived tokens for the Android app and scripts. Pass as
<code>Authorization: Bearer <token></code>. The token's full value is
only shown once at creation — copy it (or scan the QR) immediately.
</p>
<form method="post" action="/api-tokens" class="card bg-base-200 p-4 grid grid-cols-1 md:grid-cols-3 gap-2 items-end">
<label class="flex flex-col md:col-span-1">
<span class="text-xs">Label (e.g. "Pixel 7")</span>
<input class="input input-sm" type="text" name="label" placeholder="my phone"/>
</label>
<label class="flex flex-col md:col-span-1">
<span class="text-xs">Expires in days (blank = never)</span>
<input class="input input-sm" type="number" min="1" name="days" placeholder="365"/>
</label>
<button class="btn btn-primary btn-sm md:col-span-1" type="submit">Generate token</button>
</form>
{% if tokens|length == 0 %}
<p class="opacity-70 text-sm">No tokens yet.</p>
{% else %}
<div class="overflow-x-auto">
<table class="table table-sm">
<thead>
<tr>
<th>Status</th>
<th>Label</th>
<th>Token (masked)</th>
<th>Last used</th>
<th>Expires</th>
<th></th>
</tr>
</thead>
<tbody>
{% for t in tokens %}
{% set expired = t.expires_at and (t.expires_at | string) < (now | string) %}
<tr class="{% if expired %}opacity-50{% endif %}">
<td>
{% if expired %}<span class="badge badge-warning badge-sm">Expired</span>
{% else %}<span class="badge badge-success badge-sm">Active</span>
{% endif %}
</td>
<td>{{ t.label or "—" }}</td>
<td><code class="text-xs">{{ t.token[:8] }}…{{ t.token[-4:] }}</code></td>
<td class="text-xs">{{ t.last_used_at or "never" }}</td>
<td class="text-xs">{{ t.expires_at or "never" }}</td>
<td>
<form method="post" action="/api-tokens/{{ t.id }}/delete">
<button class="btn btn-error btn-xs" type="submit">Revoke</button>
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endif %}
</div>
{% endblock %}
⭐
Log in to mark this repository.
2.4 KiB · text
History
d9ed3b6