question

Dylan Hunt avatar image
Dylan Hunt asked

Not quite sure what I'm doing wrong with Photon integration (from lobby/init)

  1. I ensure that I'm using the PlayFab token for Photon (and not directly from them).
  2. I login to PlayFab via email or FB
  3. I call PhotonCustomAuthRequest()
  4. On the callback returning an PhotonCustomAuthenticationToken, I call PhotonMgr.SetAuthVals:
// Need some auth values (before we connect)
AuthenticationValues customAuth = new AuthenticationValues();


// Important: Select authentication type (how / where the auth is verified)
customAuth.AuthType = CustomAuthenticationType.Custom;


// The demo authentication-service expects values for "username" and token
customAuth.AddAuthParameter("username", pfUsername);
customAuth.AddAuthParameter("token", _photonAuthTicket);


// Connect to the photon server
PhotonNetwork.ConnectUsingSettings(PHOTON_GAME_VER);
Debug.LogFormat("PlayFab Auth Ticket Received: {0}", _photonAuthTicket);
Debug.Log(PhotonNetwork.AuthValues.ToString());


// Ready
PhotonNetwork.AuthValues = customAuth;

Here is what unexpectedly returns:

Operation failed: OperationResponse 230: ReturnCode: 32755 (Failed to parse token from request). Parameters: {} Server: NameServer
UnityEngine.Debug:LogError(Object)
NetworkingPeer:OnOperationResponse(OperationResponse) (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:1534)
ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(Byte[])
ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands()
ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
PhotonHandler:Update() (at Assets/Photon Unity Networking/Plugins/PhotonNetwork/PhotonHandler.cs:15
apisAuthentication
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hamza Lazaar avatar image
Hamza Lazaar answered

Hi @Dylan Hunt

You need to set AuthenticationValues before connecting.

AuthenticationValues customAuth = new AuthenticationValues();
customAuth.AuthType = CustomAuthenticationType.Custom;
customAuth.AddAuthParameter("username", pfUsername);
customAuth.AddAuthParameter("token", _photonAuthTicket);
PhotonNetwork.AuthValues = customAuth; // set auth values before connecting
PhotonNetwork.ConnectUsingSettings(PHOTON_GAME_VER);
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Dylan Hunt avatar image Dylan Hunt commented ·

!!!!!!!!!!!!! oh wow :) testing now, but going to assume this should work if you don't hear back from me! Thank you :D

0 Likes 0 ·
brendan avatar image
brendan answered

Since the issue is specifically an error when calling the Photon Manager, we would really need to have Exit Games weigh in on this, as they own that SDK. @Hamza Lazaar, can you or another member of the team answer this?

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

ekojim avatar image
ekojim answered

Hi there. Sorry but i have same issue. Here is my code:

  public void OnLoginWithEmailAndPasswordSucces()
    {
        GetUserDataRequest request = new GetUserDataRequest();
        PlayFabClientAPI.GetUserData(request, SetPlayerData, OnPlayFabError);
    }


    private void SetPlayerData(GetUserDataResult result)
    {
        Debug.Log("Player data loaded.");
        foreach (var item in result.Data)
        {
            Debug.Log("    " + item.Key + " == " + item.Value.Value);
        }


        if (result.Data.ContainsKey("nickName"))
        {
            Debug.Log("val:" + result.Data["nickName"].Value);
        }
        else
        {
          
            Debug.Log(result.Data.Keys);
        }
        PhotonLogin();
    }


    public void PhotonLogin()
    {
        loginPanel.SetActive(false);
        GetPhotonAuthenticationTokenRequest request = new GetPhotonAuthenticationTokenRequest();
        request.PhotonApplicationId = photonComponent.AppId.Trim();

        // get an authentication ticket to pass on to Photon
        PlayFabClientAPI.GetPhotonAuthenticationToken(request, OnPhotonTokenGet, OnPlayFabError);
    }
    
   
    void OnPhotonTokenGet(GetPhotonAuthenticationTokenResult result)
    {
        Debug.Log("OnPhotonAuthenticationSuccess");


        string _photonToken = result.PhotonCustomAuthenticationToken;
        photonComponent.PhotonToken = _photonToken;
        photonComponent.PlayFabID = this.PlayFabId;

        Debug.Log(string.Format("Yay, logged in in session token: {0}", _photonToken));
    
        AuthenticationValues customAuth = new AuthenticationValues();
        customAuth.AuthType = CustomAuthenticationType.Custom;
        customAuth.AddAuthParameter("username", photonComponent.PlayFabID);
        customAuth.AddAuthParameter("token", photonComponent.PhotonToken);
        PhotonNetwork.AuthValues = customAuth; // set auth values before connecting
        PhotonNetwork.ConnectUsingSettings(photonComponent.gameVersion);
    }



What i do wrong. I tried to find any fresh manual about, how to easy and fast fit PlayFab and Photon. But found just old, dusty 'Turn based manual' with old classes and etc.

And what Log says me:

OnPhotonAuthenticationSuccess
UnityEngine.Debug:Log(Object)
Yay, logged in in session token: yfeudaa3puz6rzos8ag9u9kg9jx835nst87f6j4kkd6rnd4cbs
UnityEngine.Debug:Log(Object)
OnStatusChanged: Connect current State: ConnectingToNameServer
UnityEngine.Debug:Log(Object)
Connected to NameServer.
UnityEngine.Debug:Log(Object)
OnStatusChanged: EncryptionEstablished current State: ConnectingToNameServer
UnityEngine.Debug:Log(Object)
Operation failed: OperationResponse 230: ReturnCode: 32755 (Invalid token). Parameters: {} Server: NameServer
UnityEngine.Debug:LogError(Object)
Custom Authentication failed (either due to user-input or configuration or AuthParameter string format). Calling: OnCustomAuthenticationFailed()
UnityEngine.Debug:LogError(Object)
OnStatusChanged: Disconnect current State: Disconnecting
UnityEngine.Debug:Log(Object)
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Dylan Hunt avatar image Dylan Hunt commented ·

Are you using the SPECIAL Photon API key found from Playfab (not Photon) website?

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.