holmes-alf is a wrapper for OAuth 2 synchronous (based on alf) and asynchronous (based on the tornado-alf) clients that can be used in holmes.
The following features are supported by both alf and tornado-alf:
- Automatic token retrieving and renewing
- Token expiration control
- Automatic retry on status 401 (UNAUTHORIZED)
Set the following config variables:
AUTHNZ_WRAPPER = 'holmesalf.wrapper.AlfAuthNZWrapper'
OAUTH_TOKEN_ENDPOINT = 'https://oauth-service.com/token-endpoint'
OAUTH_CLIENT_ID = 'client-id'
OAUTH_CLIENT_SECRET = 'client-secret'
Next, you have a sync and an async client at your disposal:
ipdb> type(self.application.authnz_wrapper)
<class 'holmesalf.wrapper.AlfAuthNZWrapper'>
ipdb> type(self.application.authnz_wrapper.sync_client)
<class 'alf.client.Client'>
ipdb> type(self.application.authnz_wrapper.async_client)
<class 'tornadoalf.client.Client'>
MIT licensed.