firebase_admin/_user_mgt.py
def update_user(self, uid, display_name=None, email=None, phone_number=None,
                    photo_url=None, password=None, disabled=None, email_verified=None,
                    valid_since=None, custom_claims=None):
        """Updates an existing user account with the specified properties"""
        payload = {
            'localId': _auth_utils.validate_uid(uid, required=True),
            'email': _auth_utils.validate_email(email),
            'password': _auth_utils.validate_password(password),
            'validSince': _auth_utils.validate_timestamp(valid_since, 'valid_since'),
            'emailVerified': bool(email_verified) if email_verified is not None else None,
            'disableUser': bool(disabled) if disabled is not None else None,
        }

        remove = []
        if display_name is not None:
            if display_name is DELETE_ATTRIBUTE:
                remove.append('DISPLAY_NAME')
            else:
                payload['displayName'] = _auth_utils.validate_display_name(display_name)
        if photo_url is not None:
            if photo_url is DELETE_ATTRIBUTE:
                remove.append('PHOTO_URL')
            else:
                payload['photoUrl'] = _auth_utils.validate_photo_url(photo_url)
        if remove:
            payload['deleteAttribute'] = remove

        if phone_number is not None:
            if phone_number is DELETE_ATTRIBUTE:
                payload['deleteProvider'] = ['phone']
            else:
                payload['phoneNumber'] = _auth_utils.validate_phone(phone_number)

        if custom_claims is not None:
            if custom_claims is DELETE_ATTRIBUTE:
                custom_claims = {}
            json_claims = json.dumps(custom_claims) if isinstance(
                custom_claims, dict) else custom_claims
            payload['customAttributes'] = _auth_utils.validate_custom_claims(json_claims)

        payload = {k: v for k, v in payload.items() if v is not None}
        try:
            body, http_resp = self._client.body_and_response(
                'post', '/accounts:update', json=payload)
        except requests.exceptions.RequestException as error:
            raise _auth_utils.handle_auth_backend_error(error)
        else:
            if not body or not body.get('localId'):
                raise _auth_utils.UnexpectedResponseError(
                    'Failed to update user: {0}.'.format(uid), http_response=http_resp)
            return body.get('localId')
Updates an existing user account with the specified properties
Updates an existing user account with the specified properties
Updates an existing user account with the specified properties
def update_user(self, uid, display_name=None, email=None, phone_number=None,
                    photo_url=None, password=None, disabled=None, email_verified=None,
                    valid_since=None, custom_claims=None):
        payload = {
            'localId': _auth_utils.validate_uid(uid, required=True),
            'email': _auth_utils.validate_email(email),
            'password': _auth_utils.validate_password(password),
            'validSince': _auth_utils.validate_timestamp(valid_since, 'valid_since'),
            'emailVerified': bool(email_verified) if email_verified is not None else None,
            'disableUser': bool(disabled) if disabled is not None else None,
        }
        remove = []
        if display_name is not None:
            if display_name is DELETE_ATTRIBUTE:
                remove.append('DISPLAY_NAME')
            else:
                payload['displayName'] = _auth_utils.validate_display_name(display_name)
        if photo_url is not None:
            if photo_url is DELETE_ATTRIBUTE:
                remove.append('PHOTO_URL')
            else:
                payload['photoUrl'] = _auth_utils.validate_photo_url(photo_url)
        if remove:
            payload['deleteAttribute'] = remove
        if phone_number is not None:
            if phone_number is DELETE_ATTRIBUTE:
                payload['deleteProvider'] = ['phone']
            else:
                payload['phoneNumber'] = _auth_utils.validate_phone(phone_number)
        if custom_claims is not None:
            if custom_claims is DELETE_ATTRIBUTE:
                custom_claims = {}
            json_claims = json.dumps(custom_claims) if isinstance(
                custom_claims, dict) else custom_claims
            payload['customAttributes'] = _auth_utils.validate_custom_claims(json_claims)
        payload = {k: v for k, v in payload.items() if v is not None}
        try:
            body, http_resp = self._client.body_and_response(
                'post', '/accounts:update', json=payload)
        except requests.exceptions.RequestException as error:
            raise _auth_utils.handle_auth_backend_error(error)
        else:
            if not body or not body.get('localId'):
                raise _auth_utils.UnexpectedResponseError(
                    'Failed to update user: {0}.'.format(uid), http_response=http_resp)
            return body.get('localId')
def update_user ( self , uid , display_name = None , email = None , phone_number = None , photo_url = None , password = None , disabled = None , email_verified = None , valid_since = None , custom_claims = None ) : payload = { 'localId' : _auth_utils . validate_uid ( uid , required = True ) , 'email' : _auth_utils . validate_email ( email ) , 'password' : _auth_utils . validate_password ( password ) , 'validSince' : _auth_utils . validate_timestamp ( valid_since , 'valid_since' ) , 'emailVerified' : bool ( email_verified ) if email_verified is not None else None , 'disableUser' : bool ( disabled ) if disabled is not None else None , } remove = [ ] if display_name is not None : if display_name is DELETE_ATTRIBUTE : remove . append ( 'DISPLAY_NAME' ) else : payload [ 'displayName' ] = _auth_utils . validate_display_name ( display_name ) if photo_url is not None : if photo_url is DELETE_ATTRIBUTE : remove . append ( 'PHOTO_URL' ) else : payload [ 'photoUrl' ] = _auth_utils . validate_photo_url ( photo_url ) if remove : payload [ 'deleteAttribute' ] = remove if phone_number is not None : if phone_number is DELETE_ATTRIBUTE : payload [ 'deleteProvider' ] = [ 'phone' ] else : payload [ 'phoneNumber' ] = _auth_utils . validate_phone ( phone_number ) if custom_claims is not None : if custom_claims is DELETE_ATTRIBUTE : custom_claims = { } json_claims = json . dumps ( custom_claims ) if isinstance ( custom_claims , dict ) else custom_claims payload [ 'customAttributes' ] = _auth_utils . validate_custom_claims ( json_claims ) payload = { k : v for k , v in payload . items ( ) if v is not None } try : body , http_resp = self . _client . body_and_response ( 'post' , '/accounts:update' , json = payload ) except requests . exceptions . RequestException as error : raise _auth_utils . handle_auth_backend_error ( error ) else : if not body or not body . get ( 'localId' ) : raise _auth_utils . UnexpectedResponseError ( 'Failed to update user: {0}.' . format ( uid ) , http_response = http_resp ) return body . get ( 'localId' )
Updates an existing user account with the specified properties
Updates an existing user account with the specified properties
"""Updates an existing user account with the specified properties"""
self
uid
display_name
email
phone_number
photo_url
password
disabled
email_verified
valid_since
custom_claims