question

Daniel Madera avatar image
Daniel Madera asked

Setting Active Server Value by API request

Hi, I'm using postman to test this API and I'm not sure why I getting this error. What are the steps I need to follow to log in and consume this API?

![7024-image.png][1]

multiplayer
image.png (63.1 KiB)
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

Please note that for security reasons, the Entity Token will expire after a certain period of time. As https://learn.microsoft.com/en-us/gaming/playfab/sdks/postman/postman-quickstart#getting-a-title-entity-token mentions that “Entity tokens expire after 24 hours. Afterwards, you need to re-run GetEntityToken to get a new entity token and update your environment variable”. So, you need to refresh the Entity Token by calling the API GetEntityToken. And after you call it, the token's expiration time will be returned as a property (TokenExpiration) in GetEntityTokenResponse.

10 |1200

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

Daniel Madera avatar image
Daniel Madera answered

7018-image.pngThanks, I got it!

Now, this is the response { "code": 401, "status": "Unauthorized", "error": "NotAuthorized", "errorCode": 1089, "errorMessage": "Only entities of the following types may call this API: title" }

Is there any possibility to login as "title" using postan?


image.png (53.2 KiB)
10 |1200

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

Daniel Madera avatar image
Daniel Madera answered

this code allowed me to change the standby value for a particular region.

 var PlayFabServer = require("playfab-sdk/Scripts/PlayFab/PlayFabMultiplayer");
 var PlayFabAuth = require("playfab-sdk/Scripts/PlayFab/PlayFabAuthentication");
    
 const dotenv = require('dotenv')
 dotenv.config({path:'../../config/config.env'});
    
    
 exports.updateBuildRegion = async function updateBuildRegion() {
    
     return new Promise((resolve, reject) => {
         PlayFab.settings.titleId = process.env.PLAYFAB_TITLE_ID;                        
         PlayFab.settings.developerSecretKey = process.env.SECRET_KEY;
            
            
         var request = {
           }
         ;
            
         PlayFabAuth.GetEntityToken(request, (error, result) => {
             if (result !== null) {         
                     
                 var request = {
                     "BuildId": "xxxxx-1154-xxxx-bc66-xxxxxxxx",
                     "BuildRegion": {
                     "Region": "EastUs",
                     "MaxServers": 1,
                     "StandbyServers": 0
                     }
                 }
                 ;
                                                        
                 PlayFabServer.UpdateBuildRegion(request, (error, result) => {
                     if (result !== null) {                                
                         resolve(result); // 
                     } else if (error !== null) {                
                         reject(CompileErrorReport(error)); // 
                     }
                 });                
             } else if (error !== null) {                
                 reject(CompileErrorReport(error)); // 
             }
         });
    
           
     });
    
 };
    
    
    
    
    
 // This is a utility function we haven't put into the core SDK yet. Feel free to use it.
 function CompileErrorReport(error) {
     if (error == null)
         return "";
     var fullErrors = error.errorMessage;
     for (var paramName in error.errorDetails)
         for (var msgIdx in error.errorDetails[paramName])
             fullErrors += "\n" + paramName + ": " + error.errorDetails[paramName][msgIdx];
     return JSON.stringify(fullErrors);
 }

While I was writing this I found out how to login as "title". I just needed to disable the X-Authorization in the Header

7031-image.png


image.png (47.3 KiB)
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.

Neils Shi avatar image Neils Shi commented ·

Thanks for sharing.

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.