question

calentine avatar image
calentine asked

I just want to require a username and password for playfab, what PlayFab::ClientModels::(?) login request should i use?

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

Sarah Zhang avatar image Sarah Zhang commented ·

In your case you can call the PlayFab API LoginWithPlayFab. If you want any sample code, could please clarify your specific development platform, is it native CPP or the unreal engine?

0 Likes 0 ·
calentine avatar image calentine commented ·

It is in unreal engine.

Thanks for replying @Sarah Zhang, I really appreciate it. Look forward to hearing from you.

0 Likes 0 ·
calentine avatar image calentine commented ·

Hey just wanted to check in if you had sample code you could either provide or point me to. Thanks again @Sarah Zhang

0 Likes 0 ·

1 Answer

·
Sarah Zhang avatar image
Sarah Zhang answered

Please refer to this document -- https://docs.microsoft.com/en-us/gaming/playfab/sdks/unreal/quickstart, especially this section -- https://docs.microsoft.com/en-us/gaming/playfab/sdks/unreal/quickstart#add-playfab-api-calls-to-your-c-loginactor.

In your case, you need to replace this code snippet

PlayFab::ClientModels::FLoginWithCustomIDRequest request;
    request.CustomId = TEXT("GettingStartedGuide");
    request.CreateAccount = true;

    clientAPI->LoginWithCustomID(request,
        PlayFab::UPlayFabClientAPI::FLoginWithCustomIDDelegate::CreateUObject(this, &ALoginActor::OnSuccess),
        PlayFab::FPlayFabErrorDelegate::CreateUObject(this, &ALoginActor::OnError)
    );

to this.

PlayFab::ClientModels::FLoginWithPlayFabRequest request;
    request.Username = TEXT("xxxxxx");
    request.Password = TEXT("xxxxxx");
    request.TitleId = TEXT("xxxxxx");


    clientAPI-> LoginWithPlayFab(request,
        PlayFab::UPlayFabClientAPI::FLoginWithPlayFabDelegate::CreateUObject(this, &ALoginActor::OnSuccess),
        PlayFab::FPlayFabErrorDelegate::CreateUObject(this, &ALoginActor::OnError)
    );
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.

calentine avatar image calentine commented ·

Thank you for the reply @Sarah Zhang. One quick question if I am creating a contoller class for playfab would making it static be ideal so the other developers can access the functions anywhere we need?

0 Likes 0 ·
Sarah Zhang avatar image Sarah Zhang calentine commented ·

You can do it. But whether it is appropriate to set the controller class to a static class depends on your specific program design. If you need any Unreal CPP source code, you can refer to our repo -- GitHub - PlayFab/UnrealMarketplacePlugin: Source code for the PlayFab Marketplace Plugin for Unreal.

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.