question

Nicolas Piechocki avatar image
Nicolas Piechocki asked

UE C++ - How to get session ticket from Custom ID Login?

I'm trying to work out a way to obtain the login results from LoginWithCustomID but I can't work out how.

So far I have this function:

PlayFabClientPtr UPlayFabAnalyticsSubsystem::Login()
{
    clientAPI = IPlayFabModuleInterface::Get().GetClientAPI();

    PlayFab::ClientModels::FLoginWithCustomIDRequest request;

    // Setting parameters to the requests so we can actually get an user account with PlayFab
    request.CustomId = TEXT("GettingStartedGuide");
    request.CreateAccount = true;

    clientAPI->LoginWithCustomID(
        request, nullptr, PlayFab::FPlayFabErrorDelegate::CreateUObject(this, &UPlayFabAnalyticsSubsystem::OnError));

    return clientAPI;

}

But when I call

            clientAPI->WriteTitleEvent(requestTitleEvent, nullptr,
                PlayFab::FPlayFabErrorDelegate::CreateUObject(this, &UPlayFabAnalyticsSubsystem::OnError));

I get the "You must log in before calling this function" Error on the first time it's executed, on later executions it works fine. I understand that I could use the SessionTicket from LoginResult but I can't work out how to do it in C++. Could you please help me?

Thanks a lot!

Authentication
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

·
Xiao Zha avatar image
Xiao Zha answered

Since PlayFab API calls are asynchronous, if you calling other APIs before the login method completes execution, the API you call will fail due to lack of data set after the login method completes. You can manually wait a period of time before calling other APIs.

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.

Nicolas Piechocki avatar image Nicolas Piechocki commented ·

Thanks, I've worked out a more "elegant" way to solve my problem which is using the Initialize() routine in the Unreal Engine subsystem, that manages to make the login with enough time to then post all the relevant events. I think that if we face this problem again we'll try to use a sort of queue system.

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.