Playfab authentication and photon

I'm using playfab new authentication method to connect to photon server. Each time I connect a player without any problem, I can get a photontoken ( https://api.playfab.com/Documentation/Client/method/GetPhotonAuthenticationToken ) with a session id.
After that I create a Photon client (Marmalade C++) - With authentication parameter set like that :
LoadBalancing::AuthenticationValues authentication(photonToken);
photonClient(*this, GetappID(), L"1.0", username, connectionProtocol, authenticationValues, autoLobbyStats, useDefaultRegion);
...
connect();
...
Each time I try to connect, the following error occured : "Impossible to parse token"

Two questions :
1- What must I do to resolve this ? It works if I use my old photon server, with no authentication.
2- Is there any way to modify the authenticate value if the server object is already created, and pass an empty value in the constructor ?

Comments

  • Hi He2.

    There is no AuthenticationValues Constructor overload, which would accept a token as first and only parameter.

    Currently (v4.0.2.2) class AuthenticationValues offers the following constructors:

    [code2=cpp]AuthenticationValues(nByte type=CustomAuthenticationType::NONE, const Common::JString& parameters=Common::JString(), const Common::JVector<nByte>& data=Common::JVector<nByte>());
    AuthenticationValues(const Common::JVector<nByte>& data);
    AuthenticationValues(const Common::JString& username, const Common::JString& token, const Common::JVector<nByte>& data=Common::JVector<nByte>());
    AuthenticationValues(const Common::JString& parameters, const Common::JVector<nByte>& data=Common::JVector<nByte>());[/code2]
    As you can see, only the 3rd overload has a "token" parameter and even that overload expects the token as the second parameter, not as the first one.
    Your code would pass the token as "parameters" to the 4th overload.


    I don't understand, what you are asking in question 2.
  • Yes, you're right, my bad, sorry for that, I read the code too quickly. After using this overloaded method :
    [code2=cpp]AuthenticationValues(const Common::JString& username, const Common::JString& token, const Common::JVector<nByte>& data=Common::JVector<nByte>());[/code2]The return code is : Authentication failed wrong user name. I pass the playfab username (so a unique one). Any idea where this can come from ?

    My second question is easy to understand, I first create a C++ object named GameServer. I just would like to know if once created I can change the authentication parameters.
  • > The return code is : Authentication failed wrong user name. I pass the playfab username (so a unique one). Any idea where this can come from ?
    Its coming from the playfab custom auth webservice. Have you had a look at this https://playfab.com/using-photon-playfab?

    They have a ticket based system - if you see their doc they have this:

    // get an authentication ticket to pass on to Photon
    PlayFabClientAPI.GetPhotonAuthenticationToken(request, OnPhotonAuthenticationSuccess, OnPlayFabError);
    Not sure you have to do with your marmelade/native client though.
  • As far as I can understand from the playfab doc that Philip has linked you need to pass the PlayFabId - that you get in your playfab login response - as Photon custom auth username, not the playfab username that you pass to the playfab login request.

    To come back to your second question:
    No, it is not supported to pass authentication values later on - this must be done on construction of the Photon Client class.