Custom authentication problems

Options
Hello,

I'm trying to configure custom auth pointing to my server, it works well for me by using http but it does not work when using https (https with self-signed certificate), basically when the Authentication URL is configured with https I never receive any request on my server from Photon. I verified that the https server is correctly configured on my server side with nginx.

Another issue it's I want to pass a custom Message on the auth response, so the returned JSON it's something like this:

{ResultCode:1,'Message':'hello'}

What's the way to retrieve this 'Message'? I tried to debug the received response by using:
   public void OnOperationResponse(OperationResponse operationResponse)
   {
		Debug.Log(operationResponse.ToStringFull());
   }
But I didn't see the 'Message' response. Any idea how to get this value?

Thanks! :-)

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited August 2015
    Options
    Hi @kaaizen,

    There is no previously reported issue about custom authentication endpoint URL with HTTPS. I think the cause is your self-signed SSL certificate ! I don't know if that is supported by Photon servers.

    Regarding returning data in the HTTP response of custom authentication please use :
    - UserId: to return a Photon UserId, of type string. If you don't return a UserId and you don't assign one in AuthenticationValues before authenticating, a pseudo-random one (GUID) will be returned by Photon servers. In LoadBalancing client it will be set to the client's UserId, in PUN (until v1.60) it's not the case yet.
    - Data : to return any data you want, which should be a JSON object.

    so for instance you could try this :
    {'ResultCode':1, 'UserId':'JohnTube', 'Data': {'Message':'hello'}}

    from client :
    public override void OnOperationResponse(OperationResponse operationResponse) {
                base.OnOperationResponse(operationResponse);  // important to call, to keep state up to date
                switch (operationResponse.OperationCode) {
                    case OperationCode.Authenticate:
                        if (operationResponse.Parameters.ContainsKey(ParameterCode.Data)){
                            var data = (Dictionary<string, object>)operationResponse.Parameters[ParameterCode.Data];
                            var msg = data["Message"];
                        }
                    break;
                    /*
                        ...
                    */
                    default:
                    break;
                }
    }
  • kaaizen
    Options
    Thank you @JohnTube, that worked great! :-)