I can't get a user's StoreId of Microsoft Store

Masanori N 0 Reputation points
2023-12-25T13:23:03.2533333+00:00

Hello,

I'm developing an app with WinUI3 and facing a problem.

The app is already published on Microsoft Store and people can use it for free. But, I would like to introduce a subscription to the app. I succeeded in making a "subscribe to this app" logic, and I'm now trying to verify whether a user has purchased a subscription, by using Microsoft EntraID.

I followed Manage product entitlements from a service to get Azure AD access tokens (Its audience URI is https://onestore.microsoft.com/b2b/keys/create/purchase) and tried to create a Microsoft Store ID key using StoreContext.GetCustomerPurchaseIdAsync. However, it only retrieves an empty result. On the other hand, I also got Azure AD access tokens of https://onestore.microsoft.com/b2b/keys/create/collections and called StoreContext.GetCustomerCollectionsIdAsync. It returns the correct StoreId.

↓This is the manifest of EntraID

{
	"id": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa",
	"acceptMappedClaims": null,
	"accessTokenAcceptedVersion": 2,
	"addIns": [],
	"allowPublicClient": null,
	"appId": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa",
	"appRoles": [],
	"oauth2AllowUrlPathMatching": false,
	"createdDateTime": "2023-12-XXTXX:XX:XXZ",
	"description": null,
	"certification": null,
	"disabledByMicrosoftStatus": null,
	"groupMembershipClaims": null,
	"identifierUris": [],
	"informationalUrls": {
		"termsOfService": null,
		"support": null,
		"privacy": null,
		"marketing": null
	},
	"keyCredentials": [],
	"knownClientApplications": [],
	"logoUrl": null,
	"logoutUrl": null,
	"name": "titechapp-windows",
	"notes": null,
	"oauth2AllowIdTokenImplicitFlow": false,
	"oauth2AllowImplicitFlow": false,
	"oauth2Permissions": [],
	"oauth2RequirePostResponse": false,
	"optionalClaims": {
		"idToken": [],
		"accessToken": [],
		"saml2Token": []
	},
	"orgRestrictions": [],
	"parentalControlSettings": {
		"countriesBlockedForMinors": [],
		"legalAgeGroupRule": "Allow"
	},
	"passwordCredentials": [
		{
			"customKeyIdentifier": null,
			"endDate": "2025-12-XXTXX:XX:XX.XXXZ",
			"keyId": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa",
			"startDate": "2023-12-XXTXX:XX:XX.XXXZ",
			"value": null,
			"createdOn": "2023-12-XXTXX:XX:XX.XXXZ",
			"hint": "AA.",
			"displayName": "aaaaaa"
		}
	],
	"preAuthorizedApplications": [],
	"publisherDomain": null,
	"replyUrlsWithType": [
		{
			"url": "https://login.microsoftonline.com/common/oauth2/nativeclient",
			"type": "InstalledClient"
		}
	],
	"requiredResourceAccess": [
		{
			"resourceAppId": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa",
			"resourceAccess": [
				{
					"id": "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa",
					"type": "Scope"
				}
			]
		}
	],
	"samlMetadataUrl": null,
	"signInUrl": null,
	"signInAudience": "AzureADandPersonalMicrosoftAccount",
	"tags": [],
	"tokenEncryptionKeyId": null
}

↓This is the method to get StoreId

    private StoreContext context = null; 

    public async Task
Microsoft Partner Center
Microsoft Partner Center
A Microsoft website for partners that provides access to product support, a partner community, and other partner services.
1,062 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.