def __init__( self, session_db, client_config=None, server_info=None, authz_page="", response_type="", scope="", flow_type="", password=None, ): """ Initialize a Consumer instance. :param session_db: Where info are kept about sessions acts like a dictionary :param client_config: Client configuration :param server_info: Information about the server :param authz_page: :param response_type: :param scope: :param flow_type: """ if client_config is None: client_config = {} Client.__init__(self, **client_config) self.authz_page = authz_page self.response_type = response_type self.scope = scope self.flow_type = flow_type self.password = password if server_info: for endpoint in ENDPOINTS: try: setattr(self, endpoint, server_info[endpoint]) except KeyError: setattr(self, endpoint, None) else: for endpoint in ENDPOINTS: setattr(self, endpoint, None) self.sdb = session_db self.seed = rndstr().encode("utf-8") self._request = None
def __init__( self, session_db, client_config=None, server_info=None, authz_page="", response_type="", scope="", flow_type="", password=None, ): """ Initializes a Consumer instance. :param session_db: Where info are kept about sessions acts like a dictionary :param client_config: Client configuration :param server_info: Information about the server :param authz_page: :param response_type: :param scope: :param flow_type: """ if client_config is None: client_config = {} Client.__init__(self, **client_config) self.authz_page = authz_page self.response_type = response_type self.scope = scope self.flow_type = flow_type self.password = password if server_info: for endpoint in ENDPOINTS: try: setattr(self, endpoint, server_info[endpoint]) except KeyError: setattr(self, endpoint, None) else: for endpoint in ENDPOINTS: setattr(self, endpoint, None) self.sdb = session_db self.seed = rndstr()
def __init__( self, session_db, client_config=None, server_info=None, authz_page="", response_type="", scope="", flow_type="", password=None, settings=None, ): """ Initialize a Consumer instance. Keyword Args: settings Instance of :class:`OauthConsumerSettings` with configuration options. Currently used settings are: - verify_ssl - client_cert - timeout :param session_db: Where info are kept about sessions acts like a dictionary :param client_config: Client configuration :param server_info: Information about the server :param authz_page: :param response_type: :param scope: :param flow_type: """ self.settings = settings or OauthConsumerSettings() if client_config is None: client_config = {} if "verify_ssl" in client_config: warnings.warn( "Setting `verify_ssl` in `client_config` is deprecated, please use `settings` instead if you need " "to set a non-default value.", DeprecationWarning, stacklevel=2, ) self.settings.verify_ssl = client_config.pop("verify_ssl") if "client_cert" in client_config: warnings.warn( "Setting `client_cert` in `client_config` is deprecated, please use `settings` instead if you need " "to set a non-default value.", DeprecationWarning, stacklevel=2, ) self.settings.client_cert = client_config.pop("client_cert") if "timeout" in client_config: warnings.warn( "Setting `timeout` in `client_config` is deprecated, please use `settings` instead if you need " "to set a non-default value.", DeprecationWarning, stacklevel=2, ) self.settings.timeout = client_config.pop("timeout") Client.__init__(self, settings=self.settings, **client_config) self.authz_page = authz_page self.response_type = response_type self.scope = scope self.flow_type = flow_type self.password = password if server_info: for endpoint in ENDPOINTS: try: setattr(self, endpoint, server_info[endpoint]) except KeyError: setattr(self, endpoint, None) else: for endpoint in ENDPOINTS: setattr(self, endpoint, None) self.sdb = session_db self.seed = rndstr().encode("utf-8") self._request = None