Skip to main content

Find user ID from external ID

You can resolve external account IDs into EOS product user IDs through the user interface. This allows you to convert e.g. a Steam account ID into an EOS user ID. You might need to use this functionality if you're interacting with native friends lists or other platform-specific APIs.

Note that the users you are looking up must be players of your game, and they must have previously authenticated to EOS using that account.

Query users by their external IDs

To query one or more users by their external IDs, call QueryExternalIdMappings on the user interface, like so:

#include "OnlineSubsystem.h"
#include "OnlineSubsystemUtils.h"
#include "Interfaces/OnlineUserInterface.h"

// ...

IOnlineSubsystem *Subsystem = Online::GetSubsystem(WorldContextObject->GetWorld());
IOnlineIdentityPtr Identity = Subsystem->GetIdentityInterface();
IOnlineUserPtr User = Subsystem->GetUserInterface();

TArray<FString> ExternalIds;
ExternalIds.Add(TEXT("") /* External ID */)
// ... Add more external IDs here

// See "Supported external ID types" for a list of valid AuthType values to pass here.
FExternalIdQueryOptions Opts = {};
Opts.bLookupByDisplayName = false;
Opts.AuthType = TEXT("...");

User->QueryExternalIdMappings(
*Identity->GetUniquePlayerId(0) /* The local user looking up the accounts */,
Opts,
ExternalIds,
IOnlineUser::FOnQueryExternalIdMappingsComplete::CreateLambda([](
bool bWasSuccessful,
const FUniqueNetId &UserId,
const FExternalIdQueryOptions &QueryOptions,
const TArray<FString> &ExternalIds,
const FString &Error)
{
// If bWasSuccessful, you can then call GetExternalIdMapping to find the actual user ID for the external ID, like so:
for (auto ExternalId : ExternalIds)
{
auto UserId = User->GetExternalIdMapping(QueryOptions, ExternalId);
if (UserId.IsValid())
{
// This external ID could be resolved into an EOS user ID.
}
else
{
// Otherwise, this external ID couldn't be found.
}
}
}));

Supported external ID types

The list of values you can pass to AuthType is as follows:

  • EPIC
  • STEAM
  • PSN
  • XBL
  • DISCORD
  • GOG
  • NINTENDO
  • UPLAY
  • OPENID
  • APPLE