in firebase_admin/_user_mgt.py [0:0]
def get_users(self, identifiers):
"""Looks up multiple users by their identifiers (uid, email, etc.)
Args:
identifiers: UserIdentifier[]: The identifiers indicating the user
to be looked up. Must have <= 100 entries.
Returns:
list[dict[string, string]]: List of dicts representing the JSON
`UserInfo` responses from the server.
Raises:
ValueError: If any of the identifiers are invalid or if more than
100 identifiers are specified.
UnexpectedResponseError: If the backend server responds with an
unexpected message.
"""
if not identifiers:
return []
if len(identifiers) > 100:
raise ValueError('`identifiers` parameter must have <= 100 entries.')
payload = defaultdict(list)
for identifier in identifiers:
if isinstance(identifier, _user_identifier.UidIdentifier):
payload['localId'].append(identifier.uid)
elif isinstance(identifier, _user_identifier.EmailIdentifier):
payload['email'].append(identifier.email)
elif isinstance(identifier, _user_identifier.PhoneIdentifier):
payload['phoneNumber'].append(identifier.phone_number)
elif isinstance(identifier, _user_identifier.ProviderIdentifier):
payload['federatedUserId'].append({
'providerId': identifier.provider_id,
'rawId': identifier.provider_uid
})
else:
raise ValueError(
'Invalid entry in "identifiers" list. Unsupported type: {}'
.format(type(identifier)))
body, http_resp = self._make_request(
'post', '/accounts:lookup', json=payload)
if not http_resp.ok:
raise _auth_utils.UnexpectedResponseError(
'Failed to get users.', http_response=http_resp)
return body.get('users', [])