question

Kevin avatar image
Kevin asked

Managing Economy v2 catalog from Unity Editor,

We're exploring PlayFab with Economy V2 for our Unity game. We're hoping to be able to synchronize shop items that are currently defined in Unity assets with the Economy V2 catalog - in other words, create new catalog items from within the Unity Editor through an API. However, it's not clear how best to approach this with Economy V2.

The Admin API includes various endpoints for managing catalog content which sound like exactly what we would want, but these seem to only support the legacy Economy and not V2. Likewise, the server API only seems to support the legacy Economy.

The Economy API (which only applies to V2?) includes some functions like "Create Draft Item" and "Update Draft Item", which sound somewhat useful (although they don't support batch operations). However, if we use these functions from within the Editor, it seems like we can only be authenticated as a Player.

Our game doesn't support UGC and we don't want normal players to be able to create, publish, view, or delete draft items. One possible solution would be to only let certain player accounts designated as admin accounts to perform these actions, but there doesn't seem to be a way to do that.

How can we manage our Economy v2 catalog from the Unity Editor without making item-management functions available to all players? ,

apisIn-Game Economy
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

·
Gosen Gao avatar image
Gosen Gao answered

You can use Unity to implement an admin tool to do that, the APIs under Economy folder are v2 APIs, you can use them to manage your Economy v2 catalog. You can use secret key to call Authentication - Get Entity Token - REST API (PlayFab Authentication) | Microsoft Learn to get a title level entity token first, then you can call Economy v2 APIs as a title admin.

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.

Kevin avatar image Kevin commented ·

@Gosen Gao Thanks. To add to your answer: I discovered that, even though Economy V2 doesn't use the Admin API, we have to enable the Admin API in the PlayFab Editor Extension in order to get the title-level entity token - otherwise, PlayFab does not include the secret key with the request.

I don't like the way that the Editor Extensions currently works, where enabling Admin API enables it for builds (exposing your secret key) as well as in the Editor, but it's easy enough to add the UNITY_EDITOR compiler directive to the #if statements in the SDK so that the secret key and Admin features aren't compiled for builds.

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.