Custom authentication UserID and NickName not Set
Options
ahoogol
✭
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!
Sorry for my weak english
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
0
Comments
-
Any help?0
-
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.1 -
Can you log the HTTP request you're receiving @ "http://MyWebSite.com/api/account/authenticate" here?0
-
@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.0