question

chinhle avatar image
chinhle asked

Almost all APIs fail and return Unauthorized

Currently, I am having a problem while calling the API, almost all APIs fail and return Unauthorized.

At first, I followed the process: Login -> RequestMultiplayerServer, the API was still called and the client connected to the server on playfab. But the RequestMultiplayerServer API is only used to request to create a new server.

So I use the GetRemoteLoginEndpoint API instead of RequestMultiplayerServer to get the server address if it was created before to connect. But API error and return unauthorized.

I've tried getting the EntityToken and assigning the X-EntityToken header to the GetRemoteLoginEndpoint, and it doesn't work either.

After that, I tried to call other APIs and they all returned Unauthorized.

Does anyone have a solution? 338157806_888235728930122_6350462552379289199_n.png

apismultiplayersupport
10 |1200

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

1 Answer

·
Gosen Gao avatar image
Gosen Gao answered

To get a created server’s info, please use API Multiplayer Server - Get Multiplayer Server Details - REST API (PlayFab Multiplayer) | Microsoft Learn. To call this API you need a title level entity token, which can be obtained by the API Authentication - Get Entity Token - REST API (PlayFab Authentication) | Microsoft Learn. But you should not call it to get a title level entity token on the client-side, since it requires the developer secret key, which should not be exposed to the client. You can use PlayFab CloudScript using Azure Functions - PlayFab | Microsoft Learn to implement such functions.

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.

chinhle avatar image chinhle commented ·

Thank you for your response,

But, Can I get a created server’s info from the client-side? And How can I do it?

I just want to create a simple demo to see how the APIs work

0 Likes 0 ·
Gosen Gao avatar image Gosen Gao chinhle commented ·

Yes, you can get the server's info on the client-side. As I mentioned above, you can use PlayFab CloudScript using Azure Functions - PlayFab | Microsoft Learn to call API Multiplayer Server - Get Multiplayer Server Details - REST API (PlayFab Multiplayer) | Microsoft Learn. Then on the client-side, you can use Server-Side Cloud Script - Execute Function - REST API (PlayFab CloudScript) | Microsoft Learn to execute the Azure Function you implemented.

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.