question

Grant McNamara avatar image
Grant McNamara asked

I keep getting Uncaught errorLoggedIn on the Javascript SDK trying to GetPlayerProfile

Whenever a user that is logged in and has a session id wants to view their info the following error pops up.

PlayFabClientApi.js:219 Uncaught errorLoggedIn ExecuteRequestWrapper @ PlayFabClientApi.js:219 GetPlayerProfile @ PlayFabClientApi.js:409 Stats @ stats.js:31 onclick @ stats.html:17

Im pretty sure that im using the sdk correctly though. My code is below.

PlayFabClientSDK.GetPlayerProfile(GetPlayerProfileRequest, xauth, (response, error) => {
                if(error)
                {
                  OutputError(error);
                } 
                else
                {
                  // display account details
                  var result = response.data;
                  var status = result.PlayerProfile.Created;
                  OutputStatus(status);
                }
            });

Player DatasdksAccount Management
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.

epicpuppyrawrr avatar image epicpuppyrawrr commented ·

errorLoggedIn is when the player is not logged in, are you logging in the player somewhere before you call this function?

0 Likes 0 ·
Grant McNamara avatar image Grant McNamara epicpuppyrawrr commented ·

yes the page can only be accessed if they are logged in. I can also only get the session ticket it they are logged in which is being used.

0 Likes 0 ·
Sarah Zhang avatar image
Sarah Zhang answered

@Grant McNamara
Thanks for your detailed clarification. Assuming you set the xauth correctly. The specific error of the API call should be “the result.PlayerProfile.Created is undefined”. To get the status of the property – Created, you would need to specify the

"ProfileConstraints": {"ShowCreated": true }

To let the API return this property, the detailed test code is this.

  // build http request object for LoginWithCustomId
    var GetPlayerProfileRequest = { "ProfileConstraints": {
        "ShowCreated": true
    }};
    GetPlayerProfileRequest.TitleId = id;

   ("Logging into PlayFab...");
    PlayFabClientSDK.GetPlayerProfile(GetPlayerProfileRequest, (response, error) => {
        if (error) {
            console.log(error);
        }
        else {
            // display account details
            var result = response.data;
            var status = "Login Successful. <br \\> Welcome Player: " + result.PlayerProfile.Created;
            console.log(status);
        }
    });

Besides, as the original answer said, before you call this Client API - GetPlayerProfile, you need to navigate to your [Game Manager]->[Title settings]->[Client Profile Options] or navigate to the URL - https://developer.playfab.com/en-US/r/t/[YourTitleId]/settings/profile-view-constraints (Please change the [YourTitleId] to the real TitleId) to check the option [Created date] to allow the API return the Created data. Otherwise, the API also won’t return the Created property. It’s by design. Please check the documentation - Account Management - Get Player Profile - REST API (PlayFab Client) | Microsoft Docs for more information.

10 |1200

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

Sarah Zhang avatar image
Sarah Zhang answered

We cannot locate the specific causes of the error according to the current code snippet you provided. Could you please provide the detailed code snippet that corresponding to the error? Specifically, could you please provide the definitions of the GetPlayerProfileRequest, xauth, OutputError, OutputStatus for our reference?

Besides, please note, after you logged a player in successfully, our SDK will store the Session Ticket in the internal variable and fill it to the headers of other client API automatically, so you needn’t to pass it using your custom variable – xauth. And, as the API reference - Account Management - Get Player Profile - REST API (PlayFab Client) | Microsoft Docs said, if you want to allow the client API to access the player profile, you would need to navigate to your title’s [Game Manager]->[Title Settings]->[Client Profile Options] tab to check the corresponding properties before you call the API.

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.

Grant McNamara avatar image Grant McNamara commented ·

the get player profile request is like the following

var GetPlayerProfileRequest = {};

GetPlayerProfileRequest.TitleId = 5E974;

I cant figure out what goes into returning only certain values but it should return all avaiable.

xauth is the session ticket that you get for logging in and i confirmed this. Its also stored as a variable. I based this off of the Playfab sdk cdn example.
0 Likes 0 ·
Grant McNamara avatar image
Grant McNamara answered

@sarah zhang

the code to get this is.

btw i made it so it gets the session ticket from localstorage

function Stats()
          {
            // fetch title id
            var id = document.getElementById("titleId").value;

            if(!id || id == "")
            {
              OutputError("TitleId cannot be null");
              return;
            }
            else if(typeof PlayFab == 'undefined') // make sure we have the SDK prior to calling / setting 
            {
              OutputError("The PlayFab SDK could not be found. Double check your script sources");
              return;
            }

            // save these values locally to ease use
            localStorage.titleId = id;
            
            // save title id
            PlayFab.settings.titleId = id;

            // build http request object for LoginWithCustomId
            var GetPlayerProfileRequest = {};
            GetPlayerProfileRequest.TitleId = id;

            OutputStatus("Logging into PlayFab...");
            PlayFabClientSDK.GetPlayerProfile(GetPlayerProfileRequest, localStorage.xauth,(response, error) => {
                if(error)
                {
                  OutputError(error);
                } 
                else
                {
                  // display account details
                  var result = response.data;
                  var status = "Login Successful. <br \\> Welcome Player: " + result.PlayerProfile.Created
                  OutputStatus(status);
                }
            });
          }; 

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.

Error rendering WebPanel (widgets/consolidation-widget.ftl): org.hibernate.hql.internal.ast.QuerySyntaxException: AvailableConsolidation is not mapped [from AvailableConsolidation up where up.node = :node]