question

Jaehoon Choi avatar image
Jaehoon Choi asked

server.SendAccountRecoveryEmail is not a function

Hi there,

I defined cloudscript for SendAccountRecoveryEmail. I ran and failed.

handlers.reqSendAccountRecoveryEmail = function (args, context) {
    var accountInfo = server.GetUserAccountInfo({
        PlayFabId: currentPlayerId
    })
    log.debug({"accountInfo": accountInfo});
    var request = {
        Email: accountInfo.UserInfo.PrivateInfo.Email
    };
    var response = server.SendAccountRecoveryEmail(request);
    log.debug("response", {response: response});
    return { responseContent: response };
};

Following is the log

{
    "FunctionResult": null,
    "Logs": [
        {
            "Level": "Debug",
            "Message": "...",
            "Data": null
        }
    ],
    "ExecutionTimeSeconds": 0.0500327,
    "MemoryConsumedBytes": 13472,
    "APIRequestsIssued": 1,
    "HttpRequestsIssued": 0,
    "Error": {
        "Error": "JavascriptException",
        "Message": "JavascriptException",
        "StackTrace": "TypeError: server.SendAccountRecoveryEmail is not a function\n    at handlers.reqSendAccountRecoveryEmail (4D6D5-main.js:45:27)\n    at Object.invokeFunction (Script:116:33)"
    }
}

I have no idea why this fails.

Did I miss something?

,

Hi there,

I defined cloudscript and tried to call SendAccountRecoveryEmail in automation.

handlers.reqSendAccountRecoveryEmail = function (args, context) {
    var accountInfo = server.GetUserAccountInfo({
        PlayFabId: currentPlayerId
    })
    log.debug({"accountInfo": accountInfo});
    var request = {
        Email: accountInfo.UserInfo.PrivateInfo.Email
    };
    var response = server.SendAccountRecoveryEmail(request);
    log.debug("response", {response: response});
    return { responseContent: response };
};

It fails and I have no idea why this fails. Following is the error log.

    "ExecutionTimeSeconds": 0.0500327,
    "MemoryConsumedBytes": 13472,
    "APIRequestsIssued": 1,
    "HttpRequestsIssued": 0,
    "Error": {
        "Error": "JavascriptException",
        "Message": "JavascriptException",
        "StackTrace": "TypeError: server.SendAccountRecoveryEmail is not a function\n    at handlers.reqSendAccountRecoveryEmail (4D6D5-main.js:45:27)\n    at Object.invokeFunction (Script:116:33)"
    }

Is there anything I missed?

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

·
Seth Du avatar image
Seth Du answered

SendAccountRecoveryEmail API is only available in Client API set and Admin API set. It is not supported in Cloud Script as Cloud Script only allows Server API. According to your code, there is no additional verifications required in Cloud Script and I believe you may let the client send the SendAccountRecoveryEmail API. As the “Email” property is required in the request, the API is used in the scenario that the player forgets the password while still remembers the login email.

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.

Jaehoon Choi avatar image Jaehoon Choi commented ·

Thank you SethDu. I confused with client and server APIs. I needed email address and was able to get it from user profile after setting Client Profile Options as in Tutorial Get a player profile - PlayFab | Microsoft Docs.

0 Likes 0 ·
Seth Du avatar image Seth Du ♦ Jaehoon Choi commented ·

As you set the "ShowContactEmailAddresses" true in the ProfileConstraints of the API request, it will display in the callback result.

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.