question

Greggory Addison avatar image
Greggory Addison asked

Automatic Item Creation From Game Engine Throws "Not Authorized Error" Even With Following The Quick Start

I am currently following this quickstart tutorial and I am still getting an error about authentication when trying to create my item from my code.

First I Get My Entity Token And Set My Secret Key In The Runtime Settings Like This

 // This needs to call some admin call to play fab to take all of of the data availale in this asset and create a new item on play fab.
     FString DeveloperKey = "XXXXXXXXXXXXXXXXXXXXXXXX";
        
     GetMutableDefault<UPlayFabRuntimeSettings>()->TitleId = "9A9B4";
     GetMutableDefault<UPlayFabRuntimeSettings>()->DeveloperSecretKey = DeveloperKey;
    
     const auto AdminAPI = IPlayFabModuleInterface::Get().GetAuthenticationAPI();
    
     const auto NewEntity = MakeShared<PlayFab::AuthenticationModels::FEntityKey>();
     NewEntity->Id = "9A9B4";
     NewEntity->Type = "title";
        
     PlayFab::AuthenticationModels::FGetEntityTokenRequest Request;
     Request.Entity = NewEntity;
        
        
        
     AdminAPI->GetEntityToken(Request, PlayFab::UPlayFabAuthenticationAPI::FGetEntityTokenDelegate::CreateUObject(this, &UBaseItemDataContainer::OnGetEntityTokenSuccess));

Then I create my item and call CreateDraftItem from the playfab Economy API models like this

 auto ContainerPtr = MakeSharedUObject<UPlayFabAuthenticationContext>();
         ContainerPtr->SetEntityToken(Response.EntityToken);
         ContainerPtr->SetDeveloperSecretKey(GetMutableDefault<UPlayFabRuntimeSettings>()->DeveloperSecretKey);
            
    
         // Authentation Context
         PlayFab::EconomyModels::FCreateDraftItemRequest Request;
         Request.Item = NewItem;
         Request.Publish = true;
         Request.AuthenticationContext = ContainerPtr;
    
         EconomyAPI->CreateDraftItem(Request, PlayFab::UPlayFabEconomyAPI::FCreateDraftItemDelegate::CreateUObject(this, &UBaseItemDataContainer::OnCreateItemOnPlayFabSuccess),
             PlayFab::FPlayFabErrorDelegate::CreateUObject(this, &ThisClass::OnError));
apisIn-Game Economyunreal
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

·
Greggory Addison avatar image
Greggory Addison answered

The Issue was with the Item Type value not being set to a supported type.

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.

Xiao Zha avatar image Xiao Zha commented ·

Glad to hear you solved the issue. If you have any other questions, please feel free to let me know.

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.