Skip to main content

Django Expiring Token

Django Expiring Token adds token expiration on token authentication and extends the expiration time on each authenticated request.

Django Expiring Token provides a very lightweight extension to DRF’s existing token authentication. It implements the following functionalities:

  1. Tokens expire after the set time.

  2. On each authenticated request, the expiration time is updated by the set time.

Quick start

  1. Do NOT add “restframework.authtoken” to you INSTALLED_APPS.

  2. Add “django_expiring_token” to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = [
        ...
        'django_expiring_token',
    ]
  3. Include the polls URLconf in your project urls.py like this:

    path('custom-url/', include('django_expiring_token.urls')),
  4. Add the expiration time in settings.py:

    EXPIRING_TOKEN_DURATION=timedelta(hours=1)
    # Any timedelta setting can be used! If not set, the default value is 1 day
  5. Add the default authentication class in REST_FRAMEWORK settings in settings.py:

    REST_FRAMEWORK = {
        'DEFAULT_AUTHENTICATION_CLASSES': (
            ...
            'django_expiring_token.authentication.ExpiringTokenAuthentication',
            ...
        ),
    }
  6. Run python manage.py migrate to create package migrations

  7. Start the development server an you are good to go.

Tests

This build is tested against Python versions 3.4, 3.5, 3,6 with Django versions 2.0.8+

To run tests

  1. Install coverage:

    pip install coverage
  2. Run tests:

    coverage run runtest.py

Metadata

Release files for django-expiring-token 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-expiring-token 1.0.3
File Size Uploaded Provenance Actions
django-expiring-token-1.0.3.tar.gz 7.0 kB Without provenance Details for django-expiring-token-1.0.3.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-expiring-token 1.0.3
File Interpreter ABI Platform Actions
django_expiring_token-1.0.3-py3-none-any.whl Python 3 none any Details for django_expiring_token-1.0.3-py3-none-any.whl

Total release size: 15.8 kB

Release files / django-expiring-token-1.0.3.tar.gz

Download URL django-expiring-token-1.0.3.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
edc6b914e2c83704c97b4314d1041b7c281497d62d34dfb9227901a2e8fc3c6e
BLAKE2b-256 checksum
How to use checksums
5c1b537b8b830f646705103acbbf3242e3d1e7cb711d1321d83286ed19ea5f59
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.3

Release files / django_expiring_token-1.0.3-py3-none-any.whl

Download URL django_expiring_token-1.0.3-py3-none-any.whl
Size 8.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
77ce75f831e926d5f29b9400c3982b0cf8f47b8387f3bed1dea8a4cd0331a42f
BLAKE2b-256 checksum
How to use checksums
06500294caac6e206bbcd2c524d5840e4e2699a4d6bf07f7c8a5410bf97bc1c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.3

Security for django-expiring-token 1.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page