[Python] How to change drf-spectacular scheme in one microservice(DRF) to use JWT token from...

Discussão em 'Python' iniciado por Stack, Março 22, 2025.

  1. Stack

    Stack Membro Participativo

    This scheme uses a built-in JWT auth part for Swagger and I need to input token in Authorize form, but how to connect microservices so that the one microservice(DRF) used the JWT token from another microservice(FastAPI) without Authorize form?

    from drf_spectacular.extensions import OpenApiAuthenticationExtension
    from drf_spectacular.plumbing import build_bearer_security_scheme_object


    class JWTAuthScheme(OpenApiAuthenticationExtension):
    target_class = "app.auth.JWTAuthentication"
    name = "JWTAuth"

    def get_security_definition(self, auto_schema):
    return build_bearer_security_scheme_object(
    header_name="Authorization", token_prefix="Bearer"
    )

    Continue reading...

Compartilhe esta Página