def __init__(self, api_key: str = None, access_token: str = None, refresh_token: str = None, client_id: str = None, client_secret: str = None, oauth2_token_getter: Optional[ Callable[[Literal["access_token", "refresh_token"], str], str]] = None, oauth2_token_setter: Optional[Callable[ [Literal["access_token", "refresh_token"], str, str], None]] = None, timeout: int = 10, mixins: List = None, api_base: str = "api.hubapi.com", debug: bool = False, disable_auth: bool = False, **extra_options) -> None: super(BaseClient, self).__init__() # reverse so that the first one in the list because the first parent if not mixins: mixins = [] mixins.reverse() for mixin_class in mixins: if mixin_class not in self.__class__.__bases__: self.__class__.__bases__ = ( mixin_class, ) + self.__class__.__bases__ self.api_key = api_key # These are used as fallbacks if there aren't setters/getters, or if no remote tokens can be # found. The properties without `__` prefixes should generally be used instead of these. self.__access_token = access_token self.__refresh_token = refresh_token self.client_id = client_id self.client_secret = client_secret if (oauth2_token_getter is None) != (oauth2_token_setter is None): raise HubspotBadConfig( "You must either specify both the oauth2 token setter and getter, or neither." ) self.oauth2_token_getter = oauth2_token_getter self.oauth2_token_setter = oauth2_token_setter self.log = utils.get_log("hubspot3") if not disable_auth: if self.api_key and self.access_token: raise HubspotBadConfig( "Cannot use both api_key and access_token.") if not (self.api_key or self.access_token or self.refresh_token): raise HubspotNoConfig("Missing required credentials.") self.options = { "api_base": api_base, "debug": debug, "disable_auth": disable_auth, "timeout": timeout, } self.options.update(extra_options) self._prepare_connection_type()
def __init__(self, api_key: str = None, access_token: str = None, refresh_token: str = None, client_id: str = None, client_secret: str = None, timeout: int = 10, mixins: List = None, api_base: str = "api.hubapi.com", debug: bool = False, disable_auth: bool = False, **extra_options) -> None: super(BaseClient, self).__init__() # reverse so that the first one in the list because the first parent if not mixins: mixins = [] mixins.reverse() for mixin_class in mixins: if mixin_class not in self.__class__.__bases__: self.__class__.__bases__ = ( mixin_class, ) + self.__class__.__bases__ self.api_key = api_key self.access_token = access_token self.refresh_token = refresh_token self.client_id = client_id self.client_secret = client_secret self.log = utils.get_log("hubspot3") if not disable_auth: if self.api_key and self.access_token: raise HubspotBadConfig( "Cannot use both api_key and access_token.") if not (self.api_key or self.access_token or self.refresh_token): raise HubspotNoConfig("Missing required credentials.") self.options = { "api_base": api_base, "debug": debug, "disable_auth": disable_auth, "timeout": timeout, } self.options.update(extra_options) self._prepare_connection_type()
def __init__( self, api_key: str = None, access_token: str = None, refresh_token: str = None, client_id: str = None, client_secret: str = None, timeout: int = 10, api_base: str = "api.hubapi.com", debug: bool = False, disable_auth: bool = False, **extra_options: Any ) -> None: """full client constructor""" self.api_key = api_key self.access_token = access_token self.refresh_token = refresh_token self.client_id = client_id self.client_secret = client_secret if not disable_auth: if self.api_key and self.access_token: raise HubspotBadConfig("Cannot use both api_key and access_token.") if not (self.api_key or self.access_token or self.refresh_token): raise HubspotNoConfig("Missing required credentials.") self.auth = { "access_token": self.access_token, "api_key": self.api_key, "client_id": self.client_id, "client_secret": self.client_secret, "refresh_token": self.refresh_token, } self.options = { "api_base": api_base, "debug": debug, "disable_auth": disable_auth, "timeout": timeout, } self.options.update(extra_options) # rate limiting related stuff self._usage_limits = Hubspot3UsageLimits()