Does cloud save use IP address to verify requests?

Heya!

By this I mean when I have two projects open with ParrelSync, The first is fine but the second one to make a request always seems to have issues.

For context:
I initialise unity services and login
I use lobby and relay to match my players p2p,
They play a game,
I bring both players to the ranking screen scene,
When interacting in the ranking screen the rewards are saved to cloud.

Pseudo example is something like this in the ranking scene:

    void Start()
    {
        SortPlayerOrderByScore();
        AddScoreToDemoExpAndCurrency();
        StartCoroutine(nameof(LoadingScreenRemoval));
    }

    void Update()
    {
        if (_wasRewardAccepted)
            return;

        if (Input.GetKeyDown(KeyCode.R))
        {
            _wasRewardAccepted = true;
            SaveCloudDataDemoExp();
            SaveCloudDataDemoMonies();
        }
    }

    public async void SaveCloudDataDemoExp()
    {
        var mPlayerData0 = new Dictionary<string, object>
        {
            { "CloudDemoExp", _newDemoExpValue }
        };
        await CloudSaveService.Instance.Data.Player.SaveAsync(mPlayerData0);
    }

    public async void SaveCloudDataDemoMonies()
    {
        var mPlayerData0 = new Dictionary<string, object>
        {
            { "CloudDemoMonies", _newDemoMoniesValue }
        };
        await CloudSaveService.Instance.Data.Player.SaveAsync(mPlayerData0);
    }

The first will save successfully the second will get the following error message:
HttpException`1: (403) HTTP/1.1 403 Forbidden
Unity.Services.CloudSave.Internal.Http.ResponseHandler.HandleAsyncResponse
(Unity.Services.CloudSave.Internal.Http.HttpClientResponse response


Rethrow as CloudSaveException: you are not permitted to access this user’s data

Which as I can access this data if I do it first makes me wonder is this due to using 2 players from the same machine somehow invalidating the player in the cloudservice data, or am i just misunderstanding something else?

EDIT: Finished hooking this up to single player and with two projects and editors on the same computer, in unconnected single player, (i.e. no lobby or relay connection at all, and two different logged in accounts), the second one will still reliably encounter the above error.

Hi KelShaded,

There shouldn’t be any IP-based checks when it comes to authentication, my guess would be that this is related to how the Authentication package (which the Cloud Save package relies on) caches session tokens. Session tokens are cached in Player Prefs, and I think your second request is retrieving the cached token authenticated for the first user, causing the 403.

The Authentication package supports using multiple profiles to ensure the correct token is retrieved from Player Prefs so that you can correctly send requests as multiple different players, hopefully this would resolve your issue!

1 Like

Hey again,
Thank you for the quick reply and you were right that did the trick!
I found i actually commented out the profile switch i previously used to use, with the note that I don’t need this anymore now i’m logging in accounts. :smile: