question

priyanka avatar image
priyanka asked

Must be logged in to call this method why this happen !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!,

PlayFabException: Must be logged in to call this method PlayFab.PlayFabClientAPI.GetStoreItems (PlayFab.ClientModels.GetStoreItemsRequest request, System.Action`1[T] resultCallback, System.Action`1[T] errorCallback, System.Object customData, System.Collections.Generic.Dictionary`2[TKey,TValue] extraHeaders) (at Assets/PlayFabSdk/PlayFabSDK/Client/PlayFabClientAPI.cs:846) Playfab_Store.callplayfabstore () (at Assets/Playfab_Store.cs:34) StoreScript.OnPanelOpen () (at Assets/Death Match/Script/StoreScript.cs:79)

,
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

·
Sarah Zhang avatar image
Sarah Zhang answered

Because each PlayFab API has some form of security that needs to be passed in the header of each request. For Client API requests, this security is a session ticket from a login request. Or it could be your title secret key if you are making server API requests. If you want to call the Client API, you need to call it in the OnLoginSucess function. About the QuickStart of login requests, you can refer to the Unity3D quickstart. We have check this API, it works fine, so please check the Login functions in your clients.

using PlayFab;
using PlayFab.ClientModels;
using UnityEngine;

public class PlayFabLogin : MonoBehaviour
{
    public void Start()
    {
        if (string.IsNullOrEmpty(PlayFabSettings.staticSettings.TitleId)){
            PlayFabSettings.staticSettings.TitleId = "[YourTitleID]"; // Please change this value to your own titleId from PlayFab Game Manager
        }
        var request = new LoginWithCustomIDRequest { CustomId = "GettingStartedGuide", CreateAccount = true};
        PlayFabClientAPI.LoginWithCustomID(request, OnLoginSuccess, OnLoginFailure);
    }

    private void OnLoginSuccess(LoginResult result)
    {
         //>> Call Client API here <<
         var getStoreItemsRequest = new GetStoreItemsRequest { StoreId="[YourStoreId]" };// Please change this value to your own storeId from PlayFab Game Manager
        PlayFabClientAPI. GetStoreItems (getStoreItemsRequest, OnGetSuccess, OnGetFailure);

}
……
}

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.