question

Tommy avatar image
Tommy asked

Unable to LinkServerCustomId with CustomId

I had originally started using LoginWithServerCustomId for players to login, but I realized that things with IP would be linked to my servers instead of the clients. I am implementing LoginWithCustomId for players and trying to Link with the ServerCustomId.

When I try to Link, it will create a new Player instead of linking the existing one. The new player will also be used when a player logs in with the same ServerCustomId excluding all the previous unlinked information.

Start State [ServerCustomId]

Login with Custom ID [ServerCustomId] [CustomId]

LinkServerCustomId <- Problem here [ServerCustomId] [CustomId linked with NEW ServerCustomId]

Now when a player logs in with the original ServerCustomId, it will be the new linked [CustomId linked with NEW ServerCustomId]

I'm hitting the APIs directly with axios

axios.post(playfabBaseURL + "/Server/LinkServerCustomId", {

PlayFabId: playFabId,

ServerCustomId: serverCustomId,

ForceLink: true,

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

Tommy avatar image Tommy commented ·

I've also replicated this issue with new accounts.

1 Like 1 ·
Neils Shi avatar image
Neils Shi answered

From my understanding, the Link APIs should connect two existing player accounts together.

Link APIs do not connect two existing player accounts together, they are used to link other login credentials to the current account. And I think you want your accounts(currently using ServerCustomId) to use Authentication - Login With Custom ID - REST API (PlayFab Client) | Microsoft Learn to login, so, I recommend that you use Account Management - Link Custom ID - REST API (PlayFab Client) | Microsoft Learn to add custom id login credential to your accounts, then you can let them use Authentication - Login With Custom ID - REST API (PlayFab Client) | Microsoft Learn to login.

This should Link the two existing accounts together. I think you have the wrong idea here.

No, if you don’t call API Authentication - Login With Custom ID - REST API (PlayFab Client) | Microsoft Learn to create another account and just use Account Management - Link Custom ID - REST API (PlayFab Client) | Microsoft Learn to link a customId login credential to your current account should be able to complete what you want: Let all users(created by API Authentication - Login With Server Custom Id - REST API (PlayFab Server) | Microsoft Learn) have another way to login.

If there is a way to override the IP for the LoginWithServerCustomId API then that would solve all my problems.

The IP address is determined from the location the login request is sent from, so to track a player's IP, simply log in using the client API. The IP of the users that created by Authentication - Login With Server Custom Id - REST API (PlayFab Server) | Microsoft Learn will change if you link a custom Id for them and login with the custom Id.

10 |1200

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

Neils Shi avatar image
Neils Shi answered

If you want players to use LoginWithCustomID to log in to the previous ServerCustomId account, you should use API LinkCustomID instead of LinkServerCustomId. The Server Custom ID and Client Custom ID are mutually exclusive and cannot be used to retrieve the same player account. The correct process should be: 1.You have an account which uses LoginWithServerCustomId. 2.Then you should use API LinkCustomID(request body:{"CustomId": "your previous ServerCustomId"}) 3. Now you can use LoginWithCustomID to log in to the previous ServerCustomId account.

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

Tommy avatar image Tommy commented ·

Thank you for the reply. I was planning on using the LoginWithCustomID as a replacement for the LoginWithServerCustomID. I agree this could be a workaround way of doing it, but the LinkServerCustomID should work as intended. This seems like a bug to me.

0 Likes 0 ·
Tommy avatar image Tommy Tommy commented ·

Actually, unless there is a way to check if a CustomId exists before login, then this method wouldn't really work for me as I'd have to keep track of both custom Ids and not really replace the LoginWithServerCustomId.

0 Likes 0 ·
Neils Shi avatar image
Neils Shi answered

I agree this could be a workaround way of doing it, but the LinkServerCustomID should work as intended. This seems like a bug to me.

It's not a bug. From your steps we can analyze that:

  1. Start State [ServerCustomId] //You have an account which uses LoginWithServerCustomId

  2. Login with Custom ID [ServerCustomId] [CustomId] // In this step, you directly create a new account which uses LoginWithCustomId

  3. Then you used API LinkServerCustomId. It just linked the ServerCustomId for this newly created Client Custom ID account. Also, you set "ForceLink" to true(which means you unlinked the login credentials for the previous Server Custom Id account). That's why you would say "When I try to Link, it will create a new Player instead of linking the existing one". All you have to do is make those LoginWithServerCustomId accounts link with CustomId (via API LinkCustomID), then you can use LoginWithCustomID to login directly.

    Actually, unless there is a way to check if a CustomId exists before login, then this method wouldn't really work for me as I'd have to keep track of both custom Ids and not really replace the LoginWithServerCustomId.

The API LoginWithServerCustomId is used to securely login to a game client from an external server backend using a custom identifier for that player. Usually, the anonymous login mechanism like CustomId, its uniqueness should be guaranteed by the developer, so there is no way to check if a CustomId exists before login. Also, you can use UnlinkServerCustomId to unlink the related custom identifier.

10 |1200

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

Tommy avatar image
Tommy answered

@Neils Shi From my understanding, the Link APIs should connect two existing player accounts together.

Even without forcelink it will not link the new CustomID account to the existing CustomServerID account.

LinkServerCustomId should operate in the same behavior as what you described but in reverse. The fact that it's not acting in the same behavior should mean that it's a bug no?

Then you used API LinkServerCustomId. It just linked the ServerCustomId for this newly created Client Custom ID account. Also, you set "ForceLink" to true(which means you unlinked the login credentials for the previous Server Custom Id account).

This should Link the two existing accounts together. I think you have the wrong idea here.

All you have to do is make those LoginWithServerCustomId accounts link with CustomId (via API LinkCustomID), then you can use LoginWithCustomID to login directly.

Again this will not work for my purposes since I need the Client to log in, not the server, for IP tracking. When the server logs in, playfab reports the server IP instead of the player's IP. Unless there's a way to override this then I'm stuck with making the client login. If I were to make the LoginWithServerCustomId accounts link with customID, I would still have to log in on the server for every login which will not work. And since there is

no way to check if a CustomId exists before login.

I cannot skip the LoginWithServerCustomId on already linked accounts
10 |1200

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

Tommy avatar image
Tommy answered

If there is a way to override the IP for the LoginWithServerCustomId API then that would solve all my problems.

10 |1200

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

Tommy avatar image
Tommy answered

Gotcha, I think I understand now. Thank you for your patience.

So in order for me to replace LoginWithServerCustomId with LoginWithCustomId on the client side, I would need to loop through all the players (most likely with get-players-in-segment) and manually LinkCustomID to their existing account. Then I would be able to completely switch over without data loss.

I originally thought it would be possible to only do so on login, but this way could also work.

Follow up question: Is there a way to remove the existing IPs associated with an account?

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.