Custom authentication deserialization failed: Unexpected character encountered while parsing value

Options
I'm having trouble creating a Custom Authentication! I'm using a free host from 000WebHost to test Photon's multiplayer on Unity, but I get the following error in Unity debug:

OperationResponse 230: ReturnCode: 32755 (Custom authentication deserialization failed: Unexpected character encountered while parsing value: U. Path '', line 0, position 0.).

Parameters: {} Server: NameServer Address: ns.exitgames.com:5058

UnityEngine.Debug:LogError(Object)

Photon.Realtime.LoadBalancingClient:DebugReturn(DebugLevel, String) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:1835)

Photon.Realtime.LoadBalancingClient:OnOperationResponse(OperationResponse) (at Assets/Photon/PhotonRealtime/Code/LoadBalancingClient.cs:1909)

ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(StreamBuffer) (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PeerBase.cs:616)

ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands() (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/EnetPeer.cs:545)

ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands() (at C:/Dev/photon-sdk-dotnet/PhotonDotnet/PhotonPeer.cs:1473)

Photon.Pun.PhotonHandler:FixedUpdate() (at Assets/Photon/PhotonUnityNetworking/Code/PhotonHandler.cs:130)


My Unity authentication code:
using Photon.Pun;
using Photon;

public class Login : MonoBehaviour {

public InputField User_Input;
public InputField Pass_Input;
public Text Error_Text;

public string username;
public string password;

public void UserName(){
    username = User_Input.text.ToString ();
}
public void UserPass(){
    password = Pass_Input.text.ToString ();
}
public void SubmitLogin(){
    PhotonNetwork.AuthValues = new AuthenticationValues ();
    PhotonNetwork.AuthValues.AuthType = CustomAuthenticationType.Custom;
    PhotonNetwork.AuthValues.AddAuthParameter ("username", username);
    PhotonNetwork.AuthValues.AddAuthParameter ("password", password);
    PhotonNetwork.ConnectUsingSettings();
}
void OnJoinedLooby(){
    Debug.Log ("We did it");
}
void OnGUI(){
    GUILayout.Label (PhotonNetwork.connectionStateDetailed.ToString ());
}
}
My server-side code:
<?php
include "db.php";

$username = $_GET['username'];
$password = $_GET['password'];

$check = mysqli_query($conn , "SELECT * FROM accounts WHERE `username`='".$username."'");
$numrows = mysqli_num_rows($check);
if ($numrows == 0){
    die ("Username does not exist.");
}else{
    $password = md5($password);
        while($row = mysqli_fetch_assoc($check)){
            if ($password == $row['password']){
                $login_info = array(
                    "ResultCode" => 1,
                    "Message" => "You are connected!");

                    }else{
                    $login_info = array(
                        "ResultCode" => 2,
                        "Message" => "Wrong username or password");
                    }
            }
        }
    $json = json_encode($login_info);
echo $json;
?>
In the photon panel I placed Url mydomain/auth.php and I did not put any optional Key/Value Pairs

I do not know what the problem is, if anyone knows

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited February 2019
    Options
    Hi @Fulanotalgames,

    Thank you for choosing Photon!

    Do not open multiple support channels at the same time or start duplicate discussions.

    The letter "U" is a hint that it could be "Username does not exist.".
    Replace
    
    die ("Username does not exist.");
    
    with
    $login_info = array(
                            "ResultCode" => 3,
                            "Message" => "Username does not exist."
    );
    If the issue persists, use postman and send an HTTP request with proper query string values to your server and see what it returns?