async def refresh_session(self, sessionId): """ Method for /api/v1/sessions/{sessionId}/lifecycle/refresh Args: session_id {str} Returns: Session """ http_method = "post".upper() api_url = format_url(f""" {self._base_url} /api/v1/sessions/{sessionId}/lifecycle/refresh """) body = {} headers = {} request, error = await self._request_executor.create_request( http_method, api_url, body, headers) if error: return (None, None, error) response, error = await self._request_executor\ .execute(request, Session) if error: return (None, response, error) try: result = Session(self.form_response_body(response.get_body())) except Exception as error: return (None, response, error) return (result, response, None)
async def create_session(self, create_session_request, keep_empty_params=False): """ Creates a new session for a user with a valid session t oken. Use this API if, for example, you want to set the session cookie yourself instead of allowing Okta to se t it, or want to hold the session ID in order to delete a session via the API instead of visiting the logout U RL. Args: {create_session_request} Returns: Session """ http_method = "post".upper() api_url = format_url(f""" {self._base_url} /api/v1/sessions """) if isinstance(create_session_request, dict): body = create_session_request else: body = create_session_request.as_dict() headers = { "Accept": "application/json", "Content-Type": "application/json" } form = {} request, error = await self._request_executor.create_request( http_method, api_url, body, headers, form, keep_empty_params=keep_empty_params) if error: return (None, None, error) response, error = await self._request_executor\ .execute(request, Session) if error: return (None, response, error) try: result = Session(self.form_response_body(response.get_body())) except Exception as error: return (None, response, error) return (result, response, None)
async def get_session(self, sessionId, keep_empty_params=False): """ Get details about a session. Args: session_id {str} Returns: Session """ http_method = "get".upper() api_url = format_url(f""" {self._base_url} /api/v1/sessions/{sessionId} """) body = {} headers = {} form = {} request, error = await self._request_executor.create_request( http_method, api_url, body, headers, form, keep_empty_params=keep_empty_params) if error: return (None, None, error) response, error = await self._request_executor\ .execute(request, Session) if error: return (None, response, error) try: result = Session(self.form_response_body(response.get_body())) except Exception as error: return (None, response, error) return (result, response, None)