PlayEveryWare / eos_plugin_for_unity

Repository for PlayEveryWare's EOS Plugin for Unity, bringing the functionality of Epic Online Services to the Unity Game Engine.
https://eospluginforunity.playeveryware.com
288 stars 56 forks source link

GetProductUserId always returns null #258

Closed Kurtis02 closed 1 year ago

Kurtis02 commented 1 year ago

Describe the bug Calling EOSManager.Instance.GetProductUserId() is returning null, even after successful login.

To Reproduce Our login code looks like this:

    private static void EpicLogin()
    {
#if UNITY_EDITOR
        Credentials credentials = new Credentials()
        {
            Id = "localhost:8888",
            Token = "DEFAULT",
            Type = LoginCredentialType.Developer,
        };
#else
        EOSManager.EOSSingleton.EpicLauncherArgs args = EOSManager.Instance.GetCommandLineArgsFromEpicLauncher();
        Credentials credentials = new Credentials()
        {
            Token = args.authPassword,
            Type = LoginCredentialType.ExchangeCode,
        };
#endif

        LoginOptions options = new LoginOptions()
        {
            Credentials = credentials,
            ScopeFlags = AuthScopeFlags.BasicProfile,
        };

        EOSManager.Instance.StartLoginWithLoginOptions(options, OnLoginCompletion);
    }

    private static void OnLoginCompletion(Epic.OnlineServices.Auth.LoginCallbackInfo loginCallbackInfo)
    {
        if (loginCallbackInfo.ResultCode != Epic.OnlineServices.Result.Success)
        {
            Debug.LogError("Got callback with code " + loginCallbackInfo.ResultCode + " and user id " + loginCallbackInfo.LocalUserId);
            return;
        }

        Debug.Log(EOSManager.Instance.GetProductUserId()); // null (or empty string)
    }

Expected behavior GetProductUserId returns a valid product user ID.

Desktop (please complete the following information):

Additional context I need the ProductUserId to access the achievements API (I think, anyways. If not please let me know).

While trying to fix this issue, I found issue #196 . The solution here was to call StartConnectLoginWithDeviceId, however this call fails for me (EOS error: "DeviceId access credentials not found on the local device.").

Any help is appreciated.

andrew-hirata-playeveryware commented 1 year ago

Hello @Kurtis02 ! The type of connect login that you will want to do will depend a lot on your title, and what platforms you plan on supporting. If you're just wanting to get started looking at the samples and the SDK, I recommend using an Epic Account to do the connect login, which can be done with the EOSManager.StartConnectLoginWithEpicAccount method.

There is an example of it being used in the UILoginMenu, which can be installed, along with the rest of the samples, into your project when via the Unity Package Manager.

Kurtis02 commented 1 year ago

Hey Andrew,

Thanks for the quick response; using StartConnectLoginWithEpicAccount works. Much appreciated!