def send_email_action_link(self, action_type, email, action_code_settings=None): """Sends an email of the given action type Args: action_type: String. Valid values ['VERIFY_EMAIL', 'EMAIL_SIGNIN', 'PASSWORD_RESET'] email: Email of the user to whom the email will be sent action_code_settings: ``ActionCodeSettings`` object or dict (optional). Defines whether the link is to be handled by a mobile app and the additional state information to be passed in the deep link, etc. Raises: FirebaseError: If an error occurs while generating the link ValueError: If the provided arguments are invalid """ payload = { 'requestType': _auth_utils.validate_action_type(action_type), 'email': _auth_utils.validate_email(email) } if action_code_settings: payload.update(encode_action_code_settings(action_code_settings)) try: self._client.body_and_response( 'post', '/accounts:sendOobCode', json=payload) except requests.exceptions.RequestException as error: raise _auth_utils.handle_auth_backend_error(error)
def generate_email_action_link(self, action_type, email, action_code_settings=None): """Fetches the email action links for types Args: action_type: String. Valid values ['VERIFY_EMAIL', 'EMAIL_SIGNIN', 'PASSWORD_RESET'] email: Email of the user for which the action is performed action_code_settings: ``ActionCodeSettings`` object or dict (optional). Defines whether the link is to be handled by a mobile app and the additional state information to be passed in the deep link, etc. Returns: link_url: action url to be emailed to the user Raises: UnexpectedResponseError: If the backend server responds with an unexpected message FirebaseError: If an error occurs while generating the link ValueError: If the provided arguments are invalid """ payload = { 'requestType': _auth_utils.validate_action_type(action_type), 'email': _auth_utils.validate_email(email), 'returnOobLink': True } if action_code_settings: payload.update(encode_action_code_settings(action_code_settings)) body, http_resp = self._make_request('post', '/accounts:sendOobCode', json=payload) if not body or not body.get('oobLink'): raise _auth_utils.UnexpectedResponseError( 'Failed to generate email action link.', http_response=http_resp) return body.get('oobLink')
def generate_email_action_link(self, action_type, email, action_code_settings=None): """Fetches the email action links for types Args: action_type: String. Valid values ['VERIFY_EMAIL', 'EMAIL_SIGNIN', 'PASSWORD_RESET'] email: Email of the user for which the action is performed action_code_settings: ``ActionCodeSettings`` object or dict (optional). Defines whether the link is to be handled by a mobile app and the additional state information to be passed in the deep link, etc. Returns: link_url: action url to be emailed to the user Raises: ApiCallError: If an error occurs while generating the link ValueError: If the provided arguments are invalid """ payload = { 'requestType': _auth_utils.validate_action_type(action_type), 'email': _auth_utils.validate_email(email), 'returnOobLink': True } if action_code_settings: payload.update(encode_action_code_settings(action_code_settings)) try: response = self._client.body('post', '/accounts:sendOobCode', json=payload) except requests.exceptions.RequestException as error: self._handle_http_error(GENERATE_EMAIL_ACTION_LINK_ERROR, 'Failed to generate link.', error) else: if not response or not response.get('oobLink'): raise ApiCallError(GENERATE_EMAIL_ACTION_LINK_ERROR, 'Failed to generate link.') return response.get('oobLink')