import logging from typing import List from slz_api_service.const import AUTH0_API_AUDIENCE, AUTH0_DOMAIN, DEFAULT_OAUTH2_FLOW from slz_api_service.core.base_struct import BaseStruct LOG = logging.getLogger(__name__) class AuthCredentials(BaseStruct): """Auth credentials helper class.""" audience: str = AUTH0_API_AUDIENCE client_id: str = None client_secret: str = None grant_type: str = DEFAULT_OAUTH2_FLOW scope: str = 'read:files' @property def access_token_url(self) -> str: return f'https://{AUTH0_DOMAIN}/oauth/token' @property def api_base_url(self) -> str: return f'https://{AUTH0_DOMAIN}' @property def authorize_url(self) -> str: return f'https://{AUTH0_DOMAIN}/authorize' @property def client_kwargs(self) -> dict: return { 'scope': f'{self.scope}', 'token_placement': 'header', } @property def token_endpoint_auth_method(self) -> str: """ Defines the requested authentication method for the token endpoint. Possible values are 'none' (public application without a client secret), 'post' (application uses HTTP POST parameters) or 'basic' (application uses HTTP Basic). """ return 'client_secret_post' def _ignore_fields(self) -> List[str]: """ Properties to ignore when calling ``.to_dict()`` that will give us a nice dictionary to pass as kwargs for the auth flask wrapper """ return []