Why does GetAppLicenseAsync temporarily return zero add-on licenses for an owned durable add-on?

MediaRanker 0 Reputation points
2026-12-04T14:45:37.2466667+00:00

Our Microsoft Store app is a packaged x64 WPF desktop app. It uses Windows.Services.Store, calls StoreContext.GetDefault(), associates the context with the app window, and checks GetAppLicenseAsync(). The add-on is a lifetime durable. Its listing is hidden, general acquisition is stopped, and the user redeemed a promotional code.

We captured two manual checks in the shipping app on the same PC, with the same app build:

• First check: the call succeeded, the parent license was active, and AddOnLicenses.Count was 0. The app displayed Free.

• About 17 minutes later: the call again succeeded and the parent license was active. This time there was one add-on license. Its SkuStoreId matched the expected durable SKU and its IsActive flag was true. The app displayed Pro.

Those 17 minutes are the interval between observations. We do not know when the license first became available or what triggered the change.

The Store library showed the add-on as acquired. On an earlier day, a separate diagnostic process with the same package identity found the SKU in GetUserCollectionAsync(), while GetAppLicenseAsync() returned zero add-on licenses. We did not query the collection during the two manual checks above.

Under what documented conditions can ownership be visible in the Store while a successful GetAppLicenseAsync() omits that durable license? Can the add-on's availability settings affect license delivery after redemption? Is there a supported diagnostic that distinguishes a stale local license from a service-side delay?

What should a desktop app do while ownership and the app license disagree? In particular, is OfflineLicensesChanged expected to fire for a code redeemed outside the app, and when should the app retry GetAppLicenseAsync() if no event arrives? Should it offer a pending state and manual refresh, and which API should be authoritative for granting or withdrawing access without prompting an existing owner to purchase again?

Windows development | Windows App SDK
0 comments No comments

1 answer

Sort by: Most helpful
  1. AI answer

    2026-12-04T14:47:22.4566667+00:00

    Treat an empty AddOnLicenses result as a temporary reconciliation state—not proof that the lifetime entitlement was withdrawn—and retry GetAppLicenseAsync() before changing previously granted access.

    What the documented behavior establishes

    • GetAppLicenseAsync() returns the current app license and its durable add-on licenses. When the device is offline, it explicitly returns the licenses cached on that device.^1^
    • StoreAppLicense.AddOnLicenses contains durable licenses that are currently valid and entitle the user to use the add-on. Invalid or expired licenses disappear from that collection.^2^
    • GetUserCollectionAsync() answers a different question: which add-ons of the current app the user has purchased. It returns product/collection information rather than the app’s current usable license view.^3^

    Therefore, the earlier observation—collection contains the SKU while AddOnLicenses is empty—shows disagreement between purchased-product data and the current license view. The public documentation identifies offline caching as one condition that can produce an older license view, but it does not document:

    • a propagation SLA after code redemption;
    • a guaranteed maximum inconsistency interval;
    • every condition under which a successful online call can omit an owned durable;
    • a client API that identifies “stale device cache” versus “Store service has not propagated it yet.”

    The observed 17 minutes is consequently not a documented refresh period.

    Availability settings

    Hidden + Stop acquisition does not prevent this redemption scenario. Under that setting, ordinary new purchases are stopped, but previous owners and customers with promotional codes on Windows 10 or Windows 11 may still acquire the add-on.^4^

    The documentation describes these settings as acquisition and discoverability controls; it does not say that they suppress license delivery for a successfully redeemed entitlement. There is therefore no documented basis for attributing the temporary omission to those settings.

    Event and retry policy

    OfflineLicensesChanged is raised when the app’s license status changes, and its handler should call GetAppLicenseAsync() again.^5^ However, Microsoft does not specifically guarantee that an already-running app receives this event for a promotional code redeemed externally. Do not wait indefinitely for it.

    A practical application policy, not a Microsoft SLA, is:

    1. Query at startup and resume.
    2. Subscribe to OfflineLicensesChanged.
    3. If the expected durable is absent but ownership was previously confirmed, show “Checking license” and preserve access temporarily.
    4. Retry immediately, then after 30 seconds, 2 minutes, and 10 minutes.
    5. Provide a Refresh license command that repeats the same check without opening a purchase UI.
    6. Serialize refreshes because startup, resume, the event, and manual refresh can race.
    private readonly SemaphoreSlim gate = new(1, 1);
    
    private async Task RefreshLicenseAsync()
    {
        if (!await gate.WaitAsync(0)) return;
        try {
            var license = await storeContext.GetAppLicenseAsync();
            bool pro = license.AddOnLicenses.Values.Any(
                x => x.SkuStoreId == expectedSku && x.IsActive);
    
            await dispatcher.InvokeAsync(() =>
                ApplyLicenseResult(pro)); // pending/grace policy is applied here
        }
        catch (Exception ex) {
            Log($"GetAppLicenseAsync failed: 0x{ex.HResult:X8}");
            await dispatcher.InvokeAsync(ShowLicensePending);
        }
        finally { gate.Release(); }
    }
    

    Keep the event subscription for the lifetime of the owning component and unsubscribe when it is disposed.

    Granting and withdrawing access

    For client-side feature enforcement, use the expected SKU’s presence in GetAppLicenseAsync().AddOnLicenses as the usable-license signal; that is the documented API for valid durable licenses.^6^

    Use GetUserCollectionAsync(new[] { "Durable" }) diagnostically to determine whether Store collection data reports the purchase. Do not send an existing owner back through purchase merely because one license call is empty.

    Because this case demonstrates that a valid lifetime license can be temporarily absent, do not revoke previously confirmed Pro access on one successful-but-empty response. Define a bounded reconciliation policy—for example, pending/grace through the retry sequence, followed by server validation or support escalation. Applications requiring strict fail-closed security can deny access earlier, but that is an application policy rather than documented proof that ownership ended.

    For authoritative server-side validation, the Microsoft Store collection REST API can confirm whether a customer has an entitlement. It requires a service implementation and Microsoft identity platform authentication; it is not a drop-in client refresh mechanism.^7^

    Diagnostics and escalation

    Log both APIs in the same process and refresh cycle, including UTC timestamp, package identity/version, expected Store ID and SKU ID, online state, result counts, ExtendedError, exceptions/HRESULTs, Windows version, and Microsoft Store version. This makes the earlier separate-process result comparable without assuming that both processes observed the same cached state.

    LicenseManager.RefreshLicensesAsync exists, but requires the restricted storeLicenseManagement capability; do not make it a general desktop-app workaround unless that capability is approved and declared.^8^

    If an online mismatch persists through bounded retries, affects multiple customers, or is reproducible with aligned collection/license logs, open a Microsoft Partner Center support request for Store add-on/licensing or submission support. Include timestamps, product and SKU Store IDs, package identity/version, Windows and Store versions, HRESULTs or correlation details, and anonymized reproduction data. Only Microsoft support can determine whether a particular successful-but-incomplete response resulted from device-side license state or Store-service propagation.


    References

    1. StoreContext.GetAppLicenseAsync Method-Definition
    2. StoreAppLicense.AddOnLicenses Property-Definition
    3. StoreContext.GetUserCollectionAsync (IIterable<String>) Method (Windows.Services.Store) - Windows apps | Microsoft Learn
    4. Set visibility options
    5. StoreContext.OfflineLicensesChanged Event-Definition
    6. Get license info for apps and add-ons
    7. In-app purchases and trials
    8. LicenseManager.RefreshLicensesAsync(LicenseRefreshOption) Method-Definition
    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

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