question

My Studio avatar image
My Studio asked

PlayFab Photon Failed to parse token from request

Hello,

i was wondering why this is not working.

When i use the Photon from the PlayFab site im getting following error trying to connect to server:

Operation failed: OperationResponse 230: ReturnCode: 32755 (Failed to parse token from request). 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)

But once i login with PlayFab but using the Photon Cloud Server directly from the Photon Site not from the PlayFab Site everything is working fine. But why the integrated Photon from PlayFab is b*itching with the OnCustomAuthentication and how i can remove it? And why is everything working fine using from the Photon Cloud direclty?

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.

Gaming Hub avatar image Gaming Hub commented ·

Failed to parse token from request

0 Likes 0 ·
capture.jpg (46.8 KiB)
brendan avatar image
brendan answered

Yes, we have a tutorial here: https://api.playfab.com/docs/using-photon-with-playfab/.

The essential difference is that when using the PlayFab-integrated version of Photon Cloud, you must use the App IDs you get from the Add-ons Marketplace. This is because it is the Photon Cloud apps which are running in the PlayFab account which are enabled for this integration. If you're using your own App IDs from the Photon site, that will not be compatible.

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.

My Studio avatar image My Studio commented ·

I'm using the PlayFab-integrated version of Photon Cloud, i was using the tutorial which you did send me after hours of trying it is still not working and im getting the same Error. Is there somewhere like a example project?

0 Likes 0 ·
brendan avatar image
brendan answered

Can you provide the specifics of how you're calling GetPhotonAuthenticationToken and how you're then calling Photon with the token?

10 |1200

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

My Studio avatar image
My Studio answered

Well i don't since i thought its just the same Photon as Photon from ExitGames. Why do have to call it ? Since when im connecting to ExitGames Photon its working without. Is somewhere a tutorial how to do it correctly so i can use PlayFab's integrated Photon?

10 |1200

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

brendan avatar image
brendan answered

For your newer question, can you re-check how the client is making the call to Photon? After signing into PlayFab, you should be making a call something like this:

public string PhotonAppId = string.Empty;
public bool ShowDebug = true;
private string _photonAuthTicket = string.Empty;
private void LoggedInConnectToPhoton(RegistrationLinkType linkType, LoginResult loginResult)
{
    //Create our Photon Auth Token Request
    var photonCustomAuthRequest = new GetPhotonAuthenticationTokenRequest()
    {
        PhotonApplicationId = PhotonAppId.Trim()
    };
    //Call to PlayFab to get our AuthToken
    PlayFabClientAPI.GetPhotonAuthenticationToken(photonCustomAuthRequest, (result) =>
    {
        _photonAuthTicket = result.PhotonCustomAuthenticationToken;
        // you need some auth values (before we connect):
        PhotonNetwork.AuthValues = new AuthenticationValues();
        // important: select authentication type (how / where the auth is verified)
        PhotonNetwork.AuthValues.AuthType = CustomAuthenticationType.Custom;
        // the demo authentication-service expects values for "username" and "token":
        PhotonNetwork.AuthValues.AddAuthParameter("username", loginResult.PlayFabId);
        PhotonNetwork.AuthValues.AddAuthParameter("token", _photonAuthTicket);
        //Connect to the photon Server.
        PhotonNetwork.ConnectUsingSettings("0.1");
        //If we want to see info we passed, turn on the ShowDebug Flag.
        if (ShowDebug)
        {
            Debug.Log(string.Format("PlayFab Auth Ticket Received: {0}", _photonAuthTicket));
            Debug.Log(PhotonNetwork.AuthValues.ToString());
        }
    }, (error) =>
    {
        Debug.Log("Could not get Auth Ticket From Photon.");
    });
}
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 answered

Sorry about bump , but is this current?

4 comments
10 |1200

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

brendan avatar image brendan commented ·

If the question is, is the PlayFab/Photon integration only valid with the Photon App IDs you get from the Add-ons page for Photon in the PlayFab Game Manager, then the answer is yes.

0 Likes 0 ·
Dylan Hunt avatar image Dylan Hunt brendan commented ·

Haha wow I responded late. I was distracted shortly after my earlier comment :)

I had this exact issue -- I could connect fine via Photon itself (with a key from Photon's site), but when I use the add-on key and tried to add custom auth, I get the same err in return. Here is what I tried.

0 Likes 0 ·
Hamza Lazaar avatar image Hamza Lazaar Dylan Hunt commented ·

I answered your question. I hope it helps.

0 Likes 0 ·
Show more comments
Denzie Gray avatar image
Denzie Gray answered
@Brendan

@Hamza Lazaar

"If the question is, is the PlayFab/Photon integration only valid with the Photon App IDs you get from the Add-ons page for Photon in the PlayFab Game Manager, then the answer is yes."

Is the above still the case in 2020? I only see the appid I entered.


My authentication fails when I changed the Auth-URL as per this thread :

https://forum.photonengine.com/discussion/comment/52839#Comment_52839


So instead of URL format:

https://{PlayFabTitleId}.playfabapi.com/photon/authenticate
use:
https://{PlayFabTitleId}.playfablogic.com/webhook/1/prod/{PhotonSecretKey}/CustomAuth

10 comments
10 |1200

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

brendan avatar image brendan commented ·

No, that post from 2016 is out of date. Since then we updated the integration so that you just use your own App ID for Photon Realtime and Chat.

0 Likes 0 ·
Denzie Gray avatar image Denzie Gray brendan commented ·

@Brendan

Thanks for the response. I also gave a URL change that I made to the authentication path.

Assuming I have a method called "handlers.CustomAuth" in CloudScript, would this Auth-URL work?

https://{PlayFabTitleId}.playfablogic.com/webhook/1/prod/{PhotonSecretKey}/CustomAuth

0 Likes 0 ·
brendan avatar image brendan Denzie Gray commented ·

Yes, you can also find that in our quickstart on Photon, here: https://docs.microsoft.com/en-us/gaming/playfab/sdks/photon/quickstart

0 Likes 0 ·
Show more comments

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.