def __init__(
self,
base_url,
client_id,
client_secret=None,
scope=None,
token=None,
token_updater=None
):
"""
:param base_url: str Base URL for Mautic API E.g. `https://<your-domain>.mautic.net`
:param client_id: str Mautic API Public Key
:param client_secret: str Mautic API Secret Key - needed to autorefresh token
:param scope: list|str
:param token: dict with access token data
:param token_updater: function used for token autorefresh.
"""
if scope and not isinstance(scope, (list, tuple)):
scope = scope.split(',')
self.base_url = base_url.strip(' /')
self.access_token_url = base_url + '/oauth/v2/token'
self.authorization_base_url = base_url + '/oauth/v2/authorize'
if token_updater is not None and client_secret is not None:
kwargs = {
'auto_refresh_url': self.access_token_url,
'auto_refresh_kwargs': {
'client_id': client_id,
'client_secret': client_secret
},
'token_updater': token_updater
}
else:
kwargs = {}
self.session = OAuth2Session(
client_id, scope=scope, token=token, **kwargs
)
评论列表
文章目录