question

Matthew Draper avatar image
Matthew Draper asked

DeleteMasterPlayer not working

Hi, as part of Apple's requirement for players to be able to delete accounts from within a game, we're trying to call an Azure function to invoke DeleteMasterPlayer (since that is not available within the normal API)


Our Azure function (below) appears to run correctly, but the player's account does not get deleted. Any help much appreciated!

        [FunctionName("nmPFDeleteMasterAccount")]
        public static async Task<IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] FunctionExecutionContext<dynamic> req,
            HttpRequest httpRequest,
            ILogger log)
        {
            var serverSettings = new PlayFab.PlayFabApiSettings()
            {
                TitleId = Settings.TitleId,
                DeveloperSecretKey = Settings.TitleSecret
            };

            var titleAuthContext = new PlayFabAuthenticationContext();
            titleAuthContext.EntityToken = req.TitleAuthenticationContext.EntityToken;

            var request = new PlayFab.AdminModels.DeleteMasterPlayerAccountRequest()
            {
                PlayFabId = req.CallerEntityProfile.Lineage.MasterPlayerAccountId,
                AuthenticationContext = titleAuthContext
            };
 
            log.LogInformation($"Request is  : {JsonConvert.SerializeObject(request)}");
            
            var adapi = new PlayFabAdminInstanceAPI(serverSettings, titleAuthContext);
            var deleteResponse = adapi.DeleteMasterPlayerAccountAsync(request);

            return (ActionResult)new OkObjectResult($"OK");
        }
    }


Here is the output from the Azure console (EntityToken removed):


2022-02-18 16:30:18.290
Executing 'nmPFDeleteMasterAccount' (Reason='This function was programmatically called via the host APIs.', Id=996c8ea3-3f41-4d31-8f46-735aa1bb1929)

2022-02-18 16:30:18.322
Request is : {"MetaData":null,"PlayFabId":"6D5E9FEFC14C0B93","AuthenticationContext":{"ClientSessionTicket":null,"PlayFabId":null,"EntityToken":"..removed..","EntityId":null,"EntityType":null}}

2022-02-18 16:30:18.349
Executed 'nmPFDeleteMasterAccount' (Succeeded, Id=996c8ea3-3f41-4d31-8f46-735aa1bb1929, Duration=124ms)

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

Gosen Gao avatar image Gosen Gao commented ·

Could you please print the deleteResponse in the console? It should contain some helpful info.

0 Likes 0 ·
Matthew Draper avatar image
Matthew Draper answered

Fixed, we had the DeveloperSecretKey set incorrectly, we needed to do this:


            var serverSettings = new PlayFab.PlayFabApiSettings()
            {
                TitleId = Environment.GetEnvironmentVariable("PLAYFAB_TITLE_ID", EnvironmentVariableTarget.Process),
                DeveloperSecretKey = Environment.GetEnvironmentVariable("PLAYFAB_DEV_SECRET_KEY", EnvironmentVariableTarget.Process)
            };

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.

Gosen Gao avatar image Gosen Gao commented ·

I'm glad to know you have solved this issue.

0 Likes 0 ·
Matthew Draper avatar image
Matthew Draper answered

For the record, since *every* iOs submission will soon have to allow the user to delete their account, it might be good to make this easier - it currently seems like an awful lot of hoops to jump through when it could just be added to the API directly.

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.