A series of errors occurred after deleting an anonymous player account in cloud dashboard

What currently happens is that right after deleting the anonymous player from unity cloud dashboard, pressing play in unity editor first shows,
[Authentication]: Request failed: 401, {“detail”:“The session token is not valid.”,“details”:[ ],“status”:401,“title”:“INVALID_SESSION_TOKEN”}

Then,
[Authentication]: The session token is invalid and has been cleared. The associated account is no longer accessible through this login method.

After that a warning,
WebRequestException: {“detail”:“The session token is not valid.”,“details”:[ ],“status”:401,“title”:“INVALID_SESSION_TOKEN”}.

This has never happened before when I deleted an anonymous player from unity cloud, usually it just signs in with a new anonymous player. I also have not changed the script in any way that should affect this, and I have tried rolling back to previous versions when it worked perfectly fine but I suppose deleting the account messed everything up.

When I now press a button that triggers the cloud code script, on the first try it says: CloudCodeException: AccessTokenMissing Access token is missing - ensure you are signed in through the Authentication SDK and try again.

This doesn’t go away until I press play again to stop the game, then upon pressing the second time, there are no errors relating to access tokens or session tokens but two other errors, and I am almost certain the previous errors although gone are what is causing my next errors: a script error and a 422 HttpException unprocessable entity error. Before, there was never this process of warnings after deleting an anonymous player, which leads me to believe these script errors are actually caused by the deleted account.

The two errors that now appear when I try to click a button that executes some cloud code function is this:
ScriptRunner.Exceptions.CloudCodeRuntimeException: Error executing Cloud Code function. Exception type: AggregateException. Message: One or more errors occurred. (Unauthorized)

After this, no matter what I reverted the cloud code files to, the HTTP 422 error would pop up. It specifies these two specific lines:
List plantList = await GetPlants(_executionContext, _gameApiClient);

And the corresponding line in GetPlants():
var result = gameApiClient.RemoteConfigSettings.AssignSettingsGetAsync(ctx, ctx.ServiceToken, ctx.ProjectId,
ctx.EnvironmentId, null, new List { “PlantList” });

The only thing that could possibly have changed was, after deleting the anonymous player and getting the session token errors (and then these script errors), I thought it best to change the ctx.AccessToken to ctx.ServiceToken for the moment thinking unity might have been confused because the previous player was deleted.

I’ve tried changing it back and forth from AccessToken back to ServiceToken to no avail. I’ve tried clearing the session tokens, to no avail. I am not even sure anymore it’s these two lines specifically (as they occur early on. Perhaps if it gets past this point there will be more errors). Again, they all worked perfectly fine before. I am completely lost as to what could be happening here. Any help would be appreciated-

I just tried accessing the economy service, and that worked, but remote config still isn’t. :frowning:

Hey,
Could you try to isolate and create a minimal repro step?
A simple scene with only one monobehavior could help, just to sanity check it’s not something else.
From then, if the issue persists, we can do more using the project/env id.

Hello

INVALID_SESSION_TOKEN is the expected error behavior after deleting a player and trying to login to that using the cached session token.

It then gets cleared and the next attempt will give a new player.

You can detect that error and force another login if you want this to be seamless to your user.

The following cloud code error is expected since you are not logged in.

I’m not sure about HttpException unprocessable entity error error in the next run.
I’d recommend making sure you log your player id while testing this to get a better idea of what’s happening.
Also apply any logic required for your specific game needs knowing that you have a new account at this point.

I don’t think the Remote Config cloud code api supports the service token so you should stick to AccessToken for that.