Connecting server with playfab
I am trying to realtime cloud server with playfab (JavaScript API).
Using appID generated by playfab, I can get Photon Authentication Token, but I have no idea how to setCustomAuthentication.
Below code results in "Client: Error: 3101 NameServer authentication failed"
var client = new Photon.LoadBalancing.LoadBalancingClient(Photon.ConnectionProtocol.Ws, APPID, "1.0");
var authParam = "username=user1" + "&token=" + TOKEN;
client.setCustomAuthentication(authParam, Photon.LoadBalancing.Constants.CustomAuthenticationType.Custom);
client.connectToRegionMaster("EU");
Can anybody help me?
Using appID generated by playfab, I can get Photon Authentication Token, but I have no idea how to setCustomAuthentication.
Below code results in "Client: Error: 3101 NameServer authentication failed"
var client = new Photon.LoadBalancing.LoadBalancingClient(Photon.ConnectionProtocol.Ws, APPID, "1.0");
var authParam = "username=user1" + "&token=" + TOKEN;
client.setCustomAuthentication(authParam, Photon.LoadBalancing.Constants.CustomAuthenticationType.Custom);
client.connectToRegionMaster("EU");
Can anybody help me?
0
Comments
-
Hi @doldom,
Thank you for choosing Photon!
Photon custom authentication with PlayFab requires two query string parameters:
- username: PlayFabId of the user to be authenticated.
- token: token retrieved from PlayFab.
Please try the following:var client = new Photon.LoadBalancing.LoadBalancingClient(Photon.ConnectionProtocol.Ws, APPID, "1.0"); var authParam = "username=" + PLAYFABID + "&token=" + TOKEN; client.setCustomAuthentication(authParam, Photon.LoadBalancing.Constants.CustomAuthenticationType.Custom); client.connectToRegionMaster("EU");
0 -
Hi JohnTube,
Thanks for the reply. I tested with valid PLAYFABID, but it still produces same error.
0 -
Hi @doldom,
Are you using PlayFab's Node SDK or another SDK? I did not find a PlayFab JavaScript SDK.
Please make sure that:
- You are using same AppId to get the token and to connect to Photon. It should be the REALTIME APPID given by PlayFab addon (no CHAT APPID).
- You are getting the token from PlayFab every time before you connect to Photon (to avoid token expiration).
- The PLAYFABID is the same as the one for the user logged in to PlayFab.
- Log the query string "authParam" to make sure you are sending proper values.
If none of the above helped try:
- add '?' to query string:var authParam = "?username=" + PLAYFABID + "&token=" + TOKEN;
- try another protocol other thanPhoton.ConnectionProtocol.Ws
, maybe UDP or TCP.
if it still does not work, I will try to reproduce and investigate further.0 -
Hi JohnTube,
Your first suggestion was right. I tried many variation and found something wrong myself.
Your below snippet solved the problem.
var authParam = "username=" + PLAYFABID + "&token=" + TOKEN;
Thanks again.
0 -
How do you get the "TOKEN" ?0
-
0