question

dbubalo1987 avatar image
dbubalo1987 asked

Webhooks - PhotonNetwork.playerName

Hi guys,

I followed up your instructions on webhooks and Photon and still don't get one point. Right now I'm doing the following:

    private void AuthenticateWithPhoton(GetPhotonAuthenticationTokenResult obj)
    {
        LogMessage("Photon token acquired: " + obj.PhotonCustomAuthenticationToken + "  Authentication complete.");

        //We set AuthType to custom, meaning we bring our own, PlayFab authentication procedure.
        var customAuth = new AuthenticationValues { AuthType = CustomAuthenticationType.Custom };

        //We add "username" parameter. Do not let it confuse you: PlayFab is expecting this parameter to contain player PlayFab ID (!) and not username.
        customAuth.AddAuthParameter("username", _playFabPlayerIdCache);    // expected by PlayFab custom auth service

        //We add "token" parameter. PlayFab expects it to contain Photon Authentication Token issues to your during previous step.
        customAuth.AddAuthParameter("token", obj.PhotonCustomAuthenticationToken);

        //We add "token" parameter. PlayFab expects it to contain Photon Authentication Token issues to your during previous step.
        // customAuth.AddAuthParameter("NickName", obj.PhotonCustomAuthenticationToken);

        customAuth.UserId = _playFabPlayerIdCache;

        //We finally tell Photon to use this authentication parameters throughout the entire application.
        PhotonNetwork.AuthValues = customAuth;

        // ShowMenu
    }

Before I put in Username and Password and authentication worked. But how do I now set the PhotonNetwork.playerName proprely? I have a displayName also, and in another Script I used:

string PlayFabName = resultData.PlayerProfile.DisplayName;
PhotonNetwork.playerName = PlayFabName;

But I think this isn't the right thing to go? I wanted to do something like this:

customAuth.AddAuthParameter("NickName", obj.InfoResultPayload.AccountInfo.TitleInfo.DisplayName);

What I want to achieve is that a hacked client cannot change his PhotonNetwork.playerName to some name that's already existing in my database.

Thanks,

Dario

3 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.

Andy avatar image Andy ♦♦ commented ·

This looks like it's more of a Photon question than a PlayFab question. You may have better luck on the Photon forums: https://forum.photonengine.com/. @Hamza Lazaar may also be able to help out.

0 Likes 0 ·
dbubalo1987 avatar image dbubalo1987 commented ·

I'm not sure if Photon can help, I put a thread in there already, waiting for an answer. How can I ask Hanza Lazaar directly or will he read this, when he see's the @? Thank you anyways guys.

0 Likes 0 ·
dbubalo1987 avatar image dbubalo1987 commented ·

Or let's say it different:

Would it be a better way to use the PhotonNetwork.AuthValues.UserID instead of PhotonNetwork.playerName at all? Then I will change my game-logic to use this one instead of the PhotonNetwork.playerName. Then my question is as follows:

Would anything speak against replacing:

customAuth.AddAuthParameter("username", _playFabPlayerIdCache);    // expected by PlayFab custom auth service

to

customAuth.AddAuthParameter("username", _playFabDisplayName);    // expected by PlayFab custom auth service

?

Then the names would be unique, or how else do it get another player's displayName by his PlayfabID?

0 Likes 0 ·
Andy avatar image
Andy answered

Are you just asking if PlayFab's player display name is guaranteed to be unique? That can be controlled in the title's settings under General. Look for the setting called "Allow non-unique player display names" and ensure it is unchecked.

If you have another player's PlayFabId, you can get their display name via GetPlayerProfile: https://docs.microsoft.com/en-us/rest/api/playfab/client/account-management/getplayerprofile?view=playfab-rest

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.

Andy avatar image Andy ♦♦ commented ·
0 Likes 0 ·
Hamza Lazaar avatar image
Hamza Lazaar answered

Hi @dbubalo1987,

Thank you for choosing Photon!

Sorry for the delay, I came back from vacation yesterday.

Although the query string parameter key name is "username" you should set its value to the PlayFabId of the player which will be set to the Photon UserId.

Once authenticated, a user can't change his Photon UserId.

In PUN2 PhotonNetwork.playerName is removed.

We recommend migrating to PUN2.

10 |1200

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

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.