tokusumi / fastapi-cloudauth

Simple integration between FastAPI and cloud authentication services (AWS Cognito, Auth0, Firebase Authentication).
MIT License
323 stars 35 forks source link

How to catch exception or change the Scope not matched message #73

Open simouel opened 2 years ago

simouel commented 2 years ago

Hi,

Is it possible to catch the "Scope not matched" and display a more accurate message to the user.

`app.include_router( manager.router, prefix="/manager", dependencies=[Depends(auth.scope('cognitogroup1))], ) ... @router.get("/units") def list_units( current_user: AccessUser = Depends(auth.scope(['cognitogroup1'])) ): ret = []; try: print(current_user) except: raise

return "OK"

`