Download

EOS OnLoginComplete never gets called, even after successful authentication

Hi.

I’ve been trying to implement EOS/EAS into my project, it works, and I can use the Developer Auth Tool or the Account portal to login successfully, client log shows this:

LogEOSSDK: LogEOSAuth: NewUserToken: User ClientId: xyz...mNz AccountId: 55c...bf3 Access[Expires: 2022.01.06-16.05.49 Remaining: 7200.22] Refresh[Expires: 2022-01-06T22:05:49.219Z Remaining: 28800.22] State: Valid
LogEOSSDK: LogEOSAuth: GenerateUserAuth success
LogEOSSDK: LogEOSAuth: login/queryuserinfo success
LogEOSSDK: LogEOSAuth: Login Tasks Complete: 0

But the game instance never calls OnLoginStatusChange or OnLoginComplete.

I added it like this:

Identity->OnLoginStatusChangedDelegates->AddUObject(this, &UEOSGameInstance::OnLoginStatusChanged);
Identity->OnLoginCompleteDelegates->AddUObject(this, &UEOSGameInstance::OnLoginComplete);

Directly after this, there is a call to Identity->Login(0, Credentials); but the event never fires.
EOS events do get called, for example CreateSession send me the notification after it’s complete.
How could I fix this?

I’m not sure if you’ve found a solution to your issue yet, this is a proxy I’ve been using to login with my project that you can take a look at, I must stress I’m new to creating online proxy nodes so I’m not sure if I’m creating the proxy correctly.

If someone with a bit more experience happens to pop by and notices something wrong with the code I would appreciate and pointers.

I hope this helps =)

EOS_LoginProxy.h

#pragma once

#include "CoreMinimal.h"
#include "OnlineSubsystem.h"
#include "Interfaces/OnlineIdentityInterface.h"
#include "Net/OnlineBlueprintCallProxyBase.h"
#include "EOS_LoginProxy.generated.h"

/**
 * 
 */
UCLASS()
class GENESISPLUGIN_API UEOS_LoginProxy : public UOnlineBlueprintCallProxyBase
{
	GENERATED_BODY()
		FDelegateHandle LoginDelegateHandle;

	// Called when the session was created successfully
	UPROPERTY(BlueprintAssignable)
		FEmptyOnlineDelegate OnSuccess;

	// Called when there was an error creating the session
	UPROPERTY(BlueprintAssignable)
		FEmptyOnlineDelegate OnFailure;

	UFUNCTION(BlueprintCallable, meta = (BlueprintInternalUseOnly = "true", WorldContext = "WorldContextObject"), Category = "Online|EOS|Networking")
		static UEOS_LoginProxy* EOS_Login(UObject* WorldContextObject, class APlayerController* PlayerController);

	virtual void Activate() override;
	void HandleLoginComplete(int32 LocalUserNum, bool bWasSuccessful, const FUniqueNetId& UserId, const FString& Error);

	TWeakObjectPtr<APlayerController> PlayerControllerWeakPtr;
	UObject* WorldContextObject;
	
};

EOS_LoginProxy.cpp

#include "EOS_LoginProxy.h"

UEOS_LoginProxy* UEOS_LoginProxy::EOS_Login(UObject* WorldContextObject, APlayerController* PlayerController)
{
	UEOS_LoginProxy* Proxy = NewObject<UEOS_LoginProxy>();
	Proxy->WorldContextObject = WorldContextObject;
	Proxy->PlayerControllerWeakPtr = PlayerController;

	return Proxy;
}

void UEOS_LoginProxy::Activate()
{
	UE_LOG_ONLINE(Error, TEXT("EOS Login Activated"), "");
	IOnlineSubsystem* OSS = IOnlineSubsystem::Get();
	if (OSS)
	{
		IOnlineIdentityPtr Identity = OSS->GetIdentityInterface();
		if (Identity.IsValid())
		{
			FOnlineAccountCredentials AccountCredentials;
			AccountCredentials.Id = TEXT("");
			AccountCredentials.Token = TEXT("");
			AccountCredentials.Type = TEXT("accountportal");

			LoginDelegateHandle = Identity->AddOnLoginCompleteDelegate_Handle(0, FOnLoginComplete::FDelegate::CreateUObject(this, &UEOS_LoginProxy::HandleLoginComplete));
			Identity->Login(0, AccountCredentials);
		}
		else
		{
			OnFailure.Broadcast();
		}
	}
	else
	{
		OnFailure.Broadcast();
	}
}

void UEOS_LoginProxy::HandleLoginComplete(int32 LocalUserNum, bool bWasSuccessful, const FUniqueNetId& UserId, const FString& Error)
{
	if (bWasSuccessful == true)
	{
		OnSuccess.Broadcast();
	}
	else
	{
		OnFailure.Broadcast();

	}

	IOnlineSubsystem* OSS = IOnlineSubsystem::Get();
	if (OSS)
	{
		IOnlineIdentityPtr Identity = OSS->GetIdentityInterface();
		if (Identity.IsValid())
		{
			Identity->ClearOnLoginCompleteDelegate_Handle(LocalUserNum, this->LoginDelegateHandle);
			this->LoginDelegateHandle.Reset();
		}
	}
	UE_LOG_ONLINE(Error, TEXT("EOS Login Complete"), "");
}

And some test functions

bool UEOSLib::EOS_IsLoggedIn(const UObject* WorldContextObject)
{
	IOnlineSubsystem* OSS = IOnlineSubsystem::Get();
	if (OSS)
	{
		IOnlineIdentityPtr Identity = OSS->GetIdentityInterface();
		if (Identity.IsValid())
		{
			switch (Identity->GetLoginStatus(0)) {
			case ELoginStatus::LoggedIn:
				return true;
				break;
			case ELoginStatus::NotLoggedIn:
				return false;
				break;
			default:
				return false;
			}
		}
	}
    return false;
}


FString UEOSLib::EOS_GetPlayerNickName(const UObject* WorldContextObject, int32 LocalUserNum )
{   
	IOnlineSubsystem* OSS = IOnlineSubsystem::Get();
	if (OSS)
	{
		IOnlineIdentityPtr Identity = OSS->GetIdentityInterface();
		if (Identity.IsValid())
		{
			return Identity->GetPlayerNickname(LocalUserNum);
		}
	}
	return "";
}

I have the same issue. I am able to see OnLoginComplete ONLY if I give it the wrong credentials (intentionally). In that case I can see it fail.

If I put the correct credentials in, I get the same LogEOSSDK messages and no callbacks fired.