Code-Link SignInWithCodeAsync error

Hi, I’m implementing the Code-Link into my game, and while I was able to make it work, there is the Pooling feature I would like to use, but I get the same error all the time. Maybe I did not understand how it works, and I am coming here to ask for help.

My implementation is simply like this:

// Based on: https://docs.unity.com/ugs/en-us/manual/authentication/manual/platform-signin-code-link
private async Task Execute(CancellationToken cancellationToken)
{
    string identifier = SystemInfo.deviceName;

    try
    {
        var codeInfo = await AuthenticationService.Instance.GenerateSignInCodeAsync();
        await AuthenticationService.Instance.SignInWithCodeAsync(true, cancellationToken);
        Debug.Log("Sign-In with Code succeeded")
    }
    catch (Exception e)
    {
        Debug.LogException(e);
    }
}

Exception:
[Authentication]: That is not a valid token (expected 3 parts but has 1).

Check the stacktrace:
[Authentication]: That is not a valid token (expected 3 parts but has 1).

UnityEngine.Logger:LogError (string,object)
Unity.Services.Authentication.Logger:LogError (object) (at ./Library/PackageCache/com.unity.services.authentication/Runtime/Utilities/Logger.cs:18)
Unity.Services.Authentication.JwtDecoder:Decode<Unity.Services.Authentication.AccessToken> (string) (at ./Library/PackageCache/com.unity.services.authentication/Runtime/Utilities/Jwt/JwtDecoder.cs:29)
Unity.Services.Authentication.AuthenticationServiceInternal:CompleteSignIn (string,string,bool,Unity.Services.Authentication.User,string) (at ./Library/PackageCache/com.unity.services.authentication/Runtime/AuthenticationServiceInternal.cs:339)
Unity.Services.Authentication.AuthenticationServiceInternal:CompleteSignIn (Unity.Services.Authentication.SignInResponse,bool) (at ./Library/PackageCache/com.unity.services.authentication/Runtime/AuthenticationServiceInternal.cs:332)
Unity.Services.Authentication.AuthenticationServiceInternal/<HandleSignInRequestAsync>d__127:MoveNext () (at ./Library/PackageCache/com.unity.services.authentication/Runtime/AuthenticationServiceInternal.cs:278)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder:Start<Unity.Services.Authentication.AuthenticationServiceInternal/<HandleSignInRequestAsync>d__127> (Unity.Services.Authentication.AuthenticationServiceInternal/<HandleSignInRequestAsync>d__127&)
Unity.Services.Authentication.AuthenticationServiceInternal:HandleSignInRequestAsync (System.Func`1<System.Threading.Tasks.Task`1<Unity.Services.Authentication.SignInResponse>>,bool)
Unity.Services.Authentication.AuthenticationServiceInternal/<SignInWithCodeAsync>d__16:MoveNext () (at ./Library/PackageCache/com.unity.services.authentication/Runtime/AuthenticationServiceInternal.CodeLink.cs:73)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<Unity.Services.Authentication.SignInResponse>:SetResult (Unity.Services.Authentication.SignInResponse)
Unity.Services.Authentication.AuthenticationServiceInternal/<PollForCodeConfirmationAsync>d__17:MoveNext () (at ./Library/PackageCache/com.unity.services.authentication/Runtime/AuthenticationServiceInternal.CodeLink.cs:110)
System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1<Unity.Services.Authentication.SignInResponse>:SetResult (Unity.Services.Authentication.SignInResponse)
Unity.Services.Authentication.WebRequest/<SendAsync>d__15`1<Unity.Services.Authentication.SignInResponse>:MoveNext () (at ./Library/PackageCache/com.unity.services.authentication/Runtime/Network/WebRequest.cs:66)
System.Threading.Tasks.TaskCompletionSource`1<string>:SetResult (string)
Unity.Services.Authentication.WebRequest:RequestCompleted (System.Threading.Tasks.TaskCompletionSource`1<string>,long,bool,bool,string,string,System.Collections.Generic.IDictionary`2<string, string>) (at ./Library/PackageCache/com.unity.services.authentication/Runtime/Network/WebRequest.cs:198)
Unity.Services.Authentication.WebRequest/<>c__DisplayClass16_1:<SendAttemptAsync>b__0 (UnityEngine.AsyncOperation) (at ./Library/PackageCache/com.unity.services.authentication/Runtime/Network/WebRequest.cs:76)
UnityEngine.AsyncOperation:InvokeCompletionEvent ()

Okay, I’ve moved the com.unity.services.authentication version 3.3.3 to my local Packages folder to realize some debugging and found the issue.

The idToken is getting checked against null only, but it can also be string.Empty, so I’ve just modified both if checks, and both Pooling and Non-pooling methods are working as expected.

Now we need a Unity engineer to apply the fix and release a new version for us.

2 Likes

Hey! Thanks for the information, I have forwarded this to the team responsible for the package.

3 Likes