def get_saml_assertion(self, username_or_email, password, app_id, subdomain, ip_address=None):
self.clean_error()<EOL>try:<EOL><INDENT>url = self.get_url(Constants.GET_SAML_ASSERTION_URL)<EOL>data = {<EOL>'<STR_LIT>': username_or_email,<EOL>'<STR_LIT:password>': password,<EOL>'<STR_LIT>': app_id,<EOL>'<STR_LIT>': subdomain,<EOL>}<EOL>if ip_address:<EOL><INDENT>data['<STR_LIT>'] = ip_address<EOL><DEDENT>response = self.execute_call('<STR_LIT>', url, json=data)<EOL>if response.status_code == <NUM_LIT:200>:<EOL><INDENT>return self.handle_saml_endpoint_response(response)<EOL><DEDENT>else:<EOL><INDENT>self.error = str(response.status_code)<EOL>self.error_description = self.extract_error_message_from_response(response)<EOL><DEDENT><DEDENT>except Exception as e:<EOL><INDENT>self.error = <NUM_LIT><EOL>self.error_description = e.args[<NUM_LIT:0>]<EOL><DEDENT>
Generates a SAML Assertion.

:param username_or_email: username or email of the OneLogin user accessing the app
:type username_or_email: string

:param password: Password of the OneLogin user accessing the app
:type password: string

:param app_id: App ID of the app for which you want to generate a SAML token
:type app_id: integer

:param subdomain: subdomain of the OneLogin account related to the user/app
:type subdomain: string

:param ip_address: whitelisted IP address that needs to be bypassed (some MFA scenarios).
:type ip_address: string

Returns a SAMLEndpointResponse object with an encoded SAMLResponse
:return: true if success
:rtype: SAMLEndpointResponse

See https://developers.onelogin.com/api-docs/1/saml-assertions/generate-saml-assertion Generate SAML Assertion documentation