Any way to get the login message text from custom auth?

Hello!

I'm using custom authentication and I wondered if there is a way to get the message text back from the server?

When the login is successful, I send back:
{"ResultCode":2,"Message":"Authentication pass."}

It would be nice to be able to pass back some extra info with the "Authentication pass." message, like player data held in my own database. It would be great if it were possible to add extra fields to the login message, too, such as:
{"ResultCode":2,"Message":"Authentication pass.","PlayerType":"Werewolf"}

Is there any way to get to that information, or do I have to make separate calls to my own server after login?

Thanks for your help!
Jeff.

Comments

  • Philip
    Philip
    edited November 2016
    Yes!

    with our last release on the cloud we started to support that.

    You can send a json object in "Data", that will be auto converted like this:
    {
      "ResultCode": 1,
      "Data": {
        "key1": true,
        "key2": 2,
        "key3": 3.3,
        "key4": "val4",
        "key5": [
          1,
          2,
          3,
          4
        ],
        "key6": {
          "subkey1": 100
        }
      }
    }
    

    And that you can access like this in your client:
    public override void OnOperationResponse(OperationResponse operationResponse)
    {
    ...
    	switch (operationResponse.OperationCode)
    	{
    		case OperationCode.Authenticate:
    			if (operationResponse.ReturnCode == 0)
    			{
    				var data = (Dictionary<string, object>)operationResponse.Parameters[ParameterCode.Data]; // key = (byte)245
    				var boolVal = (bool)data["key1"];
    				var intVal = (int)data["key2"];
    				var doubleVal = (double)data["key3"];
    				var stringVal = (string)data["key4"];
    				var arrayVal = (object[])data["key5"];
    				var subObject = (Dictionary<string, object>)data["key6"];
    			}
    

    Note: We also support sending Data to the client without Authenticating, so you can implement flows that require a more complex authentication flow, i.e.
    to request a temporary token in a 3-legged oauth authentication.
    {
      "ResultCode": 0,
    ...
    

    Hope this helps - we haven't updated our docs jet - but the feature is actively being used by customers (for the 3-legged oauth szenario).

    -Philip