def enroll_factor(self, user_id, factor_id, display_name, number):
self.clean_error()<EOL>try:<EOL><INDENT>url = self.get_url(Constants.ENROLL_FACTOR_URL, user_id)<EOL>data = {<EOL>'<STR_LIT>': int(factor_id),<EOL>'<STR_LIT>': display_name,<EOL>'<STR_LIT>': number<EOL>}<EOL>response = self.execute_call('<STR_LIT>', url, json=data)<EOL>if response.status_code == <NUM_LIT:200>:<EOL><INDENT>json_data = response.json()<EOL>if json_data and json_data.get('<STR_LIT:data>', None):<EOL><INDENT>return OTP_Device(json_data['<STR_LIT:data>'][<NUM_LIT:0>])<EOL><DEDENT><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>
Enroll a user with a given authentication factor.

:param user_id: Set to the id of the user.
:type user_id: integer

:param factor_id: The identifier of the factor to enroll the user with.
:type factor_id: integer

:param display_name: A name for the users device.
:type display_name: string

:param number: The phone number of the user in E.164 format..
:type number: string

:return: MFA device
:rtype: OTP_Device

See https://developers.onelogin.com/api-docs/1/multi-factor-authentication/enroll-factor Enroll an Authentication Factor documentation