Sign In Register

How can we help you today?

Start a new topic

ScriptData on AuthenticationResponse is always null (Unity + Steam)

Hi,


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:


"{\"@class\":\".AuthenticationResponse\",\"authToken\":\"2f62a591-3b6b-45c1-8265-9018605f594a\",\"displayName\":\"kiwibonga\",\"newPlayer\":false,\"requestId\":\"636251739557528809_0\",\"userId\":\"57ec1f315e4c93056d87d695\"}"


I have tested this with SteamConnectRequest.


Can you think of any reason why the data isn't being passed?


Hi Benjamiin,


Can you try testing this in the Test Harness and verifying that this is happening there?


-Pádraig

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).

Hi Benjamin,


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.


-Pádraig



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).

Please confirm whether the issue is being investigated; I'd be happy to submit a formal bug report if needed.


Thanks.

I see in the Unity console that the ScriptData field is now properly populated, although we didn't make any related code changes:


{"@class":".AuthenticationResponse","authToken":"5ab2fb14-9992-4c54-8504-4427aff42308","displayName":"kiwibonga","newPlayer":false,"requestId":"636257082542738346_1","scriptData":{"permissionLevel":"10"},"userId":"57ec1f315e4c93056d87d695"}


Was the issue identified and fixed?

I still haven't received an answer to this.

Hi Benjamin, 


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. 

 Hi Benjamin,


You access can access scriptData like so:


 GSData responseData = response.scriptData;


  if (responseData.GetInt("permissionLevel").HasValue)
       {
         int permission = responseData.GetInt("permissionLevel").Value;
         Debug.Log(permission);
       }


Regards,

-Dave


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.

Login to post a comment