question

ericmallon avatar image
ericmallon asked

NotAuthorized error returned when calling CreateDraftItem after setting DeveloperSecretKey

When attempting to create a draft catalog item using the Unreal 5.0 SDK, via:

 IPlayFabModuleInterface::Get().GetEconomyAPI()->CreateDraftItem(request,
                 PlayFab::UPlayFabEconomyAPI::FCreateDraftItemDelegate::CreateUObject(this, &UPlayFabBackendService::OnCreateDraftItemSuccess),
                 PlayFab::FPlayFabErrorDelegate::CreateUObject(this, &UPlayFabBackendService::OnError));

, I am getting an error NotAuthorized, with an error code 1089 and http code 401. There are no other details within the error message.

I have set the developer secret key via GetMutableDefault()->DeveloperSecretKey = [key]

I have also previously made the call

     PlayFab::AuthenticationModels::FGetEntityTokenRequest request;
     EntityKey = MakeShareable<PlayFab::AuthenticationModels::FEntityKey>(new PlayFab::AuthenticationModels::FEntityKey());
     EntityKey->Id = [title key]
     EntityKey->Type = "title";
     request.Entity = EntityKey;
        
     IPlayFabModuleInterface::Get().GetAuthenticationAPI()->GetEntityToken(request,
             PlayFab::UPlayFabAuthenticationAPI::FGetEntityTokenDelegate::CreateUObject(this, &UPlayFabBackendService::OnFetchEntityKeySuccess),
             PlayFab::FPlayFabErrorDelegate::CreateUObject(this, &UPlayFabBackendService::OnError));

Any suggestions on what I may be missing? Based on everything I read, this should be sufficient. I've also tried without specifying any params on the FGetEntityTokenRequest (among many, many other things)

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.

Xiao Zha avatar image
Xiao Zha answered

This error may be caused by unsupported Item Type, currently Catalog - Create Draft Item - REST API (PlayFab Economy) | Microsoft Learn supported Item Types are bundle, catalogItem, currency, store, ugc.

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.

ericmallon avatar image ericmallon commented ·

Thanks! That did it. There was also the requirement of having a Title with the neutral locale, though that one at least had a clear error message.

What is the best means to request/suggest documentation + error message improvements? Here, or somewhere else?

The doc for the API, https://learn.microsoft.com/en-us/rest/api/playfab/economy/catalog/create-draft-item?view=playfab-rest#catalogitem, doesn't mention anything about that being a required field, and the FCatalogItem struct reads:

         // [optional] The high-level type of the item. The following item types are supported: bundle, catalogItem, currency, store, ugc.
         FString Type;

The biggest improvement needed of course is that getting a 401 'not authorized' error code for a missing required field is... not very illuminating!

0 Likes 0 ·
ericmallon avatar image
ericmallon answered

Another further issue: While my items do publish now, the Item ID that I pass is being overwritten and a random GUID added in its place. This adds a whole bunch of additional complexity to interacting with items, is there any way to override this behavior and enforce playfab using the specified ID?

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 ·

The random GUID is generated by PlayFab and cannot be set by developers or players. If you want to have another name for the item, you can set the AlternateIds property with a type of FriendlyId, and this AlternateId will be displayed in the published item list instead of the random GUID.

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.