API

Decorators used to integrate with BDC-Auth Provider.

bdc_auth_client.decorators.HTTP_403_MSG = "You don't have permission to access this resource."

Define a generic message related Fordibben Access (403).

bdc_auth_client.decorators.oauth2(roles=None, required=True, throw_exception=True)

Decorate a Flask route to connect with BDC-Auth Provider.

You can specify user roles required to access a resource.

Make sure to set the following variables to the app:

  • BDC_AUTH_CLIENT_ID: Application Client Id

  • BDC_AUTH_CLIENT_SECRET: Application Client Secret

  • BDC_AUTH_ACCESS_TOKEN_URL: URL to BDC-Auth Provider Token

Example

>>> from bdc_auth_client.decorators import oauth2
>>>
>>> @app.route('/')  
... @oauth2(roles=['admin'])
... def protected_route(roles=None):
...     return dict(status=200)