ankkashyap
5 months agoNew Contributor
requestInterceptor with Python
Hello ,
I have configured the swagger using FAST API for my project , Now I would like to intercept the request coming out of swagger UI . In swagger documentation I see a parameter requestInterceptor can be used for such task , but when ever I am starting my app with below mentioned code , Swagger UI starts giving me error "s.requestInterceptor is not a function /openapi.json" , I tried looking for the solution but found None
app = FastAPI(
swagger_ui_parameters={"requestSnippetsEnabled": True,"persistAuthorization":True,
"requestInterceptor": """
(req) => {
// Modify the request object as needed
req.headers['Authorization'] = 'Bearer <your_access_token>';
return req;
}
"""
}
)