SuperTokens Python SDK

repository·dev·Indexed 41 days ago

https://github.com/supertokens/supertokens-python

A client-side library for Python backends that facilitates communication with the SuperTokens HTTP service to manage authentication and sessions. It provides integration examples for frameworks such as Django, FastAPI, and Flask, including support for the ThirdpartyEmailpassword recipe for social authentication via Google, Github, Apple, and Discord.

Tokens
1.2K
Snippets
7
Records
11
Agent score
100%

What's inside SuperTokens

  1. Overview of SuperTokens Python SDK

    dev
    The SuperTokens Python SDK is a library designed to interface between a Python API process and the SuperTokens HTTP service. It enables developers to integrate SuperTokens' authentication and session management capabilities into Python-based backend applications.
  2. Configure SuperTokens Core via Docker Compose

    dev

    The compose.yaml file defines the deployment for the SuperTokens Core service and an OAuth test service. You can customize the Core service using environment variables for versioning and port mapping.

    Core Service Configuration

    • Image Versioning: Controlled by the SUPERTOKENS_CORE_VERSION environment variable. If not provided, it defaults to master.
    • Port Mapping: The Core service listens on port 3567 inside the container. You can map this to a different host port using the SUPERTOKENS_CORE_PORT environment variable (defaults to 3567).

    Core Service Environment Variables

    When running the Core service, the following environment variables are used for configuration:

    • OAUTH_PROVIDER_PUBLIC_SERVICE_URL: The public service URL for the OAuth provider (e.g., http://oauth:4444).
    • OAUTH_PROVIDER_ADMIN_SERVICE_URL: The admin service URL for the OAuth provider (e.g., http://oauth:4445).
    • OAUTH_PROVIDER_CONSENT_LOGIN_BASE_URL: The base URL for OAuth consent login (e.g., http://localhost:3001/auth).
    • OAUTH_CLIENT_SECRET_ENCRYPTION_KEY: A key used for encrypting OAuth client secrets.
    • INFO_LOG_PATH: Path for info logs (set to "null" to disable in this config).
    • ERROR_LOG_PATH: Path for error logs (set to "null" to disable in this config).
    • LOG_LEVEL: The logging verbosity (e.g., DEBUG).
    services:
      core:
        image: supertokens/supertokens-dev-postgresql:${SUPERTOKENS_CORE_VERSION:-master}
        ports:
          - ${SUPERTOKENS_CORE_PORT:-3567}:3567
        environment:
          OAUTH_PROVIDER_PUBLIC_SERVICE_URL: http://oauth:4444
          OAUTH_PROVIDER_ADMIN_SERVICE_URL: http://oauth:4445
          OAUTH_PROVIDER_CONSENT_LOGIN_BASE_URL: http://localhost:3001/auth
          OAUTH_CLIENT_SECRET_ENCRYPTION_KEY: asdfasdfasdfasdfasdf
          INFO_LOG_PATH: "null"
          ERROR_LOG_PATH: "null"
          LOG_LEVEL: "DEBUG"
    
      oauth:
        image: supertokens/oauth2-test:latest