Typing stubs for Authlib

1.6.9.20260408 · active · verified Sat Apr 11

This is a type stub package for the Authlib library, providing static type checking for Authlib code. As part of the typeshed project, it's automatically released up to once a day. This version of types-Authlib aims to provide accurate annotations for Authlib==1.6.9. [9, 8, 23]

Warnings

Install

Imports

Quickstart

This quickstart demonstrates setting up an Authlib OAuth client using Flask integration. While it's a runtime example for Authlib, its purpose here is to show code that `types-authlib` would type-check. You must install `Authlib` (e.g., `pip install Authlib Flask`) and optionally `python-dotenv` for environment variables, in addition to `types-authlib`.

import os
from flask import Flask
from authlib.integrations.flask_client import OAuth

# NOTE: For actual use, configure these securely from environment variables
# or a configuration management system, not hardcoded.
CLIENT_ID = os.environ.get('GOOGLE_CLIENT_ID', 'your-google-client-id')
CLIENT_SECRET = os.environ.get('GOOGLE_CLIENT_SECRET', 'your-google-client-secret')

app = Flask(__name__)
app.config.update({
    'SECRET_KEY': 'very-secret-key-for-session',
    'GOOGLE_CLIENT_ID': CLIENT_ID,
    'GOOGLE_CLIENT_SECRET': CLIENT_SECRET
})

oauth = OAuth(app)

oauth.register(
    name='google',
    client_id=app.config['GOOGLE_CLIENT_ID'],
    client_secret=app.config['GOOGLE_CLIENT_SECRET'],
    access_token_url='https://oauth2.googleapis.com/token',
    authorize_url='https://accounts.google.com/o/oauth2/auth',
    api_base_url='https://www.googleapis.com/oauth2/v1/',
    client_kwargs={'scope': 'openid email profile'}
)

print("Authlib OAuth client registered for Google. ")
print("This example demonstrates type-checked setup, but does not run a server.")
print("Run a type checker like MyPy on this file after installing types-authlib.")

view raw JSON →