Skip to content

Latest commit

 

History

History
64 lines (43 loc) · 1.56 KB

README.md

File metadata and controls

64 lines (43 loc) · 1.56 KB

FastID Client

FastID client for Python


Test CodeQL Advanced


Installation

pip install fastid-client

Get Started

from typing import Annotated, Any

from fastapi import Depends, FastAPI
from fastapi.responses import RedirectResponse

from examples.config import settings
from fastid_client.fastapi import FastIDClient
from fastid_client.schemas import OAuth2Callback, TokenResponse

fastid = FastIDClient(
    settings.server_url,
    settings.client_id,
    settings.client_secret,
    "http://localhost:8000/callback",
)

app = FastAPI()


@app.get("/")
async def login() -> RedirectResponse:
    async with fastid:
        return fastid.get_authorization_redirect()


@app.get("/callback", response_model=TokenResponse)
async def callback(call: Annotated[OAuth2Callback, Depends()]) -> Any:
    async with fastid:
        return await fastid.process_callback(call)

Run the server:

fastapi dev app.py

Visit http://localhost:8000 to start the authorization process.

Consent Screen

After logging into FastID, you will be redirected to the callback URL. The server will then fetch the Access Token and return it as a response. Obtained Token