From cf2100a6dfa240c5d233bfb3014c6e61b4911442 Mon Sep 17 00:00:00 2001 From: Nico de Poel Date: Tue, 13 Jul 2021 15:47:23 +0200 Subject: [PATCH] Skip the Auth login step, which is only for linked Epic accounts. We can go straight to the Connect interface with our Xbox Live XSTS token. --- Assets/Scripts/MagnificentVoiceChat.cs | 40 ++++++++++---------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/Assets/Scripts/MagnificentVoiceChat.cs b/Assets/Scripts/MagnificentVoiceChat.cs index b10c7cd..d5e25c5 100644 --- a/Assets/Scripts/MagnificentVoiceChat.cs +++ b/Assets/Scripts/MagnificentVoiceChat.cs @@ -203,18 +203,27 @@ public class MagnificentVoiceChat : MonoBehaviour } status.AppendLine("Xbox user added"); - SDK.XUserGetTokenAndSignatureUtf16Async(userHandle, XUserGetTokenAndSignatureOptions.ForceRefresh, + SDK.XUserGetTokenAndSignatureUtf16Async(userHandle, XUserGetTokenAndSignatureOptions.None, "GET", "https://api.epicgames.dev/", null, null, HandleTokenAndSignature); }); yield return new WaitUntil(() => !string.IsNullOrEmpty(xstsToken)); -#endif - + + connectInterface.Login(new Epic.OnlineServices.Connect.LoginOptions + { + Credentials = new Epic.OnlineServices.Connect.Credentials + { + Type = ExternalCredentialType.XblXstsToken, + Token = xstsToken, + }, + }, null, HandleConnectResult); +#else authInterface.Login(new LoginOptions { Credentials = GetEpicCredentials(), ScopeFlags = AuthScopeFlags.BasicProfile, }, null, HandleLoginResult); +#endif } #if UNITY_GAMECORE @@ -231,11 +240,9 @@ public class MagnificentVoiceChat : MonoBehaviour status.AppendLine("Xbox Live successfully authenticated"); xstsToken = tokenAndSignature.Token; } -#endif - - private Credentials GetEpicCredentials() // This is platform-specific +#else + private Credentials GetEpicCredentials() // This is platform-specific (actually it's not, we can skip this on consoles) { -#if UNITY_STANDALONE return new Credentials { // Type = LoginCredentialType.AccountPortal, // Use ExternalAuth on console platform @@ -243,15 +250,6 @@ public class MagnificentVoiceChat : MonoBehaviour Type = LoginCredentialType.Developer, Token = SystemInfo.deviceName, }; -#elif UNITY_GAMECORE - return new Credentials - { - Type = LoginCredentialType.ExternalAuth, - ExternalType = ExternalCredentialType.XblXstsToken, - Token = xstsToken, - }; -#elif UNITY_PS4 || UNITY_PS5 -#endif } private void HandleLoginResult(LoginCallbackInfo data) @@ -268,20 +266,11 @@ public class MagnificentVoiceChat : MonoBehaviour connectInterface.Login(new Epic.OnlineServices.Connect.LoginOptions { -#if UNITY_STANDALONE Credentials = new Epic.OnlineServices.Connect.Credentials { Type = ExternalCredentialType.Epic, // Can be XSTS or PSN ID as well, platform-specific Token = token.AccessToken, }, -#elif UNITY_GAMECORE - Credentials = new Epic.OnlineServices.Connect.Credentials - { - Type = ExternalCredentialType.XblXstsToken, // Isn't this kinda redundant? Should we be logging in to our Epic account here? - Token = xstsToken, - }, -#elif UNITY_PS4 || UNITY_PS5 -#endif }, null, HandleConnectResult); break; default: @@ -290,6 +279,7 @@ public class MagnificentVoiceChat : MonoBehaviour break; } } +#endif private void HandleConnectResult(Epic.OnlineServices.Connect.LoginCallbackInfo data) {