getUserByProviderUid method

Future<UserRecord> getUserByProviderUid({
  1. required String providerId,
  2. required String uid,
})
inherited

Gets the user data for the user corresponding to a given provider id.

See https://firebase.google.com/docs/auth/admin/manage-users#retrieve_user_data for code samples and detailed documentation.

  • providerId: The provider ID, for example, "google.com" for the Google provider.
  • uid: The user identifier for the given provider.

Returns a Future fulfilled with the user data corresponding to the given provider id.

Implementation

Future<UserRecord> getUserByProviderUid({
  required String providerId,
  required String uid,
}) async {
  // Although we don't really advertise it, we want to also handle
  // non-federated idps with this call. So if we detect one of them, we'll
  // reroute this request appropriately.
  if (providerId == 'phone') {
    return getUserByPhoneNumber(uid);
  } else if (providerId == 'email') {
    return getUserByEmail(uid);
  }

  final response = await _authRequestHandler.getAccountInfoByFederatedUid(
    providerId: providerId,
    rawId: uid,
  );

  // Returns the user record populated with server response.
  return UserRecord.fromResponse(response);
}