Custom authentication UserID and NickName not Set

Options
ahoogol
ahoogol
edited February 2016 in Photon Server
hi, i setuped photon server v4 in my own server. i red this article to configure Custom Authentication hosted in my own web server. but in PUN (v1.66) after connect, in the OnConnectedToMaster callback, i checked Nickname by PhotonNetwork.playerName but it has not value!

Codes:

1. in the Photon.LoadBalancing.dll.config in server:

<AuthSettings Enabled="true" ClientAuthenticationAllowAnonymous="false">
    <AuthProviders>
		<AuthProvider Name="MyWebSite"
					AuthenticationType="0"
					AuthUrl="http://MyWebSite.com/api/account/authenticate"/>
    </AuthProviders>
  </AuthSettings>
2. in the PUN in unity test client:

        PhotonNetwork.AuthValues = new AuthenticationValues
        {
            AuthType = CustomAuthenticationType.Custom
        };
        PhotonNetwork.AuthValues.AddAuthParameter("userName", userName);
        PhotonNetwork.AuthValues.AddAuthParameter("token", token);
        PhotonNetwork.ConnectUsingSettings(Version);
...
public override void OnConnectedToMaster()
    {
        Debug.Log("UserId=" + PhotonNetwork.AuthValues.UserId+
            ", Nickname=" + PhotonNetwork.playerName);
     }
3. in the response of authenticate service in MyWebServer:
{"ResultCode":1,"UserId":"foo@gmail.com","Nickname":"bar","Data":{"lvl":0}}

Expected Result:

in the PUN OnConnectedToMaster in result of Debug.Log:
UserId=foo@gmail.com, Nickname=bar

Incorrect Result:

but it logs:
UserId=, Nickname=

Sorry for my weak english ;)

Comments

  • ahoogol
    Options
    Any help?
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @ahoogol,

    Please try changing this part of your code:
    PhotonNetwork.AuthValues = new AuthenticationValues
    {
         AuthType = CustomAuthenticationType.Custom
    };
    to:
    PhotonNetwork.AuthValues = new AuthenticationValues();
    PhotonNetwork.AuthValues = CustomAuthenticationType.Custom;
    For more information on why this is important read this post.
  • ahoogol
    Options
    Hi @JohnTube, thanks for reply. But this change didn't affect the result. PhotonNetwork.AuthValues.UserId and PhotonNetwork.playerName are empty yet.
  • JohnTube
    JohnTube ✭✭✭✭✭
    edited February 2016
    Options
    Can you log the HTTP request you're receiving @ "http://MyWebSite.com/api/account/authenticate" here?
  • ahoogol
    ahoogol
    edited February 2016
    Options
    @JohnTube, yes it is like here:
    http://MyWebSite.com/api/account/authenticate?userName=foo@gmail.com&token=LLUpALz6Zbsw9MBFCEIxzQ==
  • ahoogol
    Options
    @JohnTube, in pun new version (1.67), the bug fixed:
    v1.67 (21. April 2016): Changed: If sent by server, UserId and Nickname values are updated (with the server's values). This can be done with CustomAuthentication. All clients always get some UserId assigned by the server (if you didn't set one in the first place).
    I tested and it is solved. ;)