Skip to content

How to update an API token

Mike Lissner edited this page Mar 18, 2024 · 1 revision

If a user needs a new API token for whatever reason, you have to fix it using Python (sorry). The admin page won't work. To do it with Python:

from rest_framework.authtoken.models import Token
old_t = Token.objects.get(user_id=xyz)
old_t.delete()
Token.objects.create(user_id=xyz)

That'll do it.