def get_auth_session(auth_config: dict, force: bool = False): global timeseries_client_auth_session if not timeseries_client_auth_session or force: timeseries_client_auth_session = requests_ms_auth.MsRequestsSession( requests_ms_auth.MsSessionConfig(**auth_config)) return timeseries_client_auth_session
def _create_session(self, force: bool = False): """Create session for the future calls.""" if not self.session or force: self.session = requests_ms_auth.MsRequestsSession( requests_ms_auth.MsSessionConfig(**self.auth_config)) if not self.session: return self._raise_exception( f"Could not create session for {self.__class__.__name__}")
def todo_test_fetch_access_token_functioning_adal(MockAuthenticationContext, auth_config_live_msal, token, expected_oath_token): """ Test that Adal auth token values result in expected OAuth tokens """ mock_auth_context = MockAuthenticationContext( authority="https://dummy-authority", validate_authority=None, api_version=None) mock_auth_context.acquire_token_with_client_credentials.return_value = token session = requests_ms_auth.MsRequestsSession(auth_config_dummy) assert session._fetch_access_token() == expected_oath_token
def todo_test_all(auth_config_live_adal): with open("secrets.json", "r") as file: data = json.load(file) for auth in data: verification_url = auth["verification_url"] verification_element = auth["verification_element"] for do_adal in [True]: auth["do_adal"] = do_adal session = requests_ms_auth.MsRequestsSession(auth) logger.warning(f"Testing {session}") # Verification ok, message = session.verify_auth() assert ok logger.warning(f"Message: {message}") # Direct res = session.get(session.msrs_verification_url) assert_json_response(res, verification_element) # Prepared req = requests.Request("GET", verification_url) res = session.send(req.prepare()) assert_json_response(res, verification_element)
def get_auth_session(self, auth_config: dict): if not self.client_auth_session: # logger.info("CREATING SESSION:") self.client_auth_session = requests_ms_auth.MsRequestsSession( requests_ms_auth.MsSessionConfig(**auth_config)) return self.client_auth_session
def get_auth_session(self, auth_config: dict): if not self.client_auth_session: self.client_auth_session = requests_ms_auth.MsRequestsSession( requests_ms_auth.MsSessionConfig(**auth_config)) return self.client_auth_session