I have this line in the cloud code for AuthenticationResponse in Preview mode:
Spark.setScriptData("permissionLevel", playerPermission); // playerPermission = "10"
I've verified that the code does run every time a user logs in by writing a log message to a runtime collection. When I try to access "response.ScriptData" from Unity, however, ScriptData is null. If I inspect the values, the JSON contains no scriptData:
I have tested this with SteamConnectRequest.
Can you think of any reason why the data isn't being passed?
Thanks for the replies. We wait for GameSparks.Core.GS.Available to become true before sending the authentication request -- is that too early? The auth request was confirmed to be successful, and the setScriptData() line was confirmed to run; can you think of anything that would explicitly strip the script data from a successful auth request response?
Since this issue resolved itself without any action on our part or yours, it's plausible that it'll happen again at some point, so I'll keep an eye out.
You access can access scriptData like so:
GSData responseData = response.scriptData;
int permission = responseData.GetInt("permissionLevel").Value;
Apologies for the delay here.
There were no changes made to the behavior of our Request Api, so unless you had made changes to the sdk it'self or the codebase, it may have been that you were attempting to send the AuthenticationRequest before successfully connected to the service.
Happy to help - Patrick.
I still haven't received an answer to this.
I see in the Unity console that the ScriptData field is now properly populated, although we didn't make any related code changes:
Was the issue identified and fixed?
Please confirm whether the issue is being investigated; I'd be happy to submit a formal bug report if needed.
Okay. I tried DeviceAuthenticationRequest in the Unity test harness scene and can confirm that there's no scriptData attached in the AuthenticationResponse (I also verified that the call to Spark.setScriptData successfully runs on the cloud code side).
And AuthenticatedConnectResponse i different from an AuthenticationResponse. The two can be confusing :D
AuthenticatedConnectResponse is returned on successful Initialisation of GameSparks. This happens automatically.
AuthenticationResponse is returned on successful Authentication (Device Auth, Regular Auth etc...). By default this should return a playerId and auth-token.
Just tried it; the script data is successfully returned in the test harness on the portal. The Unity test harness doesn't show an AuthenticationResponse being returned (only AuthenticatedConnectResponse).
Can you try testing this in the Test Harness and verifying that this is happening there?