{% extends "base.html" %} {% load i18n static wger_extras %} {% block title %}{% translate "API access" %}{% endblock %} {% block content %}
{% blocktranslate trimmed %} Theare are two ways to authenticate against the API: JWT is the preferred mechanism for client applications, the static API key is intended for personal scripts or one-off integrations. {% endblocktranslate %}
{% blocktranslate trimmed %} Refresh tokens let scripts and CLI tools talk to the wger API using the JWT flow without logging in interactively each time. {% endblocktranslate %}
{% if new_refresh_token %}
{{ new_refresh_token }}
{% blocktranslate trimmed with days=refresh_token_lifetime_days %} Refresh tokens expire {{ days }} days after they were generated, unless you revoke them sooner. {% endblocktranslate %}
| {% translate "Created" %} | {% translate "Expires" %} | |
|---|---|---|
| {{ session.long_lived.created|date:"Y-m-d H:i" }} | {{ session.expire_date|date:"Y-m-d H:i" }} |
{% endif %}
{% blocktranslate trimmed %} Revoking JWT sessions logs out every device that obtained a refresh token via the JWT login endpoint. {% endblocktranslate %}
{% if token %}
{% endif %}
{% blocktranslate with key=token.key|default:"1234567890abcde..." %}
Pass Token {{ key }} in the
Authorization header to use it.
{% endblocktranslate %}
{% translate "Example with curl:" %}
curl -X GET https://wger.de/api/v2/routine/ \
-H 'Authorization: Token {% if token %}{{ token.key }}{% else %}1234567890abcde...{% endif %}'
{% endblock %}
{# #}
{# Sidebar #}
{# #}
{% block sidebar %}