Beispiel #1
0
        private async Task GenerateMSStoreIDAndSyncToService()
        {
            // 1. get collection/purchase Azure AD access token from service
            var authResult = await GetTokenFromAzureOAuthAsync();

            // 2. generate MS Store ID by collection and purchase Azure AD access token
            string uid = "*****@*****.**";
            // publisherUserId is identify user on your server, such as: serial id, not Microsoft Account
            var collectionStoreId = await storeContext.GetCustomerCollectionsIdAsync(authResult.Collection, uid);

            var purchaseStoreId = await storeContext.GetCustomerPurchaseIdAsync(authResult.Purchase, uid);

            // 3. report MS Store ID to service
            var actionData = new PostActionData()
            {
                UID               = uid,
                AuthData          = authResult,
                CollectionStoreID = collectionStoreId,
                PurchaseStoreID   = purchaseStoreId
            };

            HttpClient client  = new HttpClient();
            var        content = new HttpStringContent(actionData.Stringify());

            content.Headers.ContentType = new HttpMediaTypeHeaderValue("application/json");
            var result = await client.PostAsync(new Uri("http://localhost/api/values"), content);

            var responseContent = await result.Content.ReadAsStringAsync();

            Debug.WriteLine(responseContent);
        }
        private async void GetCustomerCollectionsId()
        {
            string aadToken = await GetTokenFromAzureOAuthAsync();

            if (!String.IsNullOrEmpty(aadToken))
            {
                string id = await storeContext.GetCustomerCollectionsIdAsync(aadToken, "*****@*****.**");

                Output.Text = id;
                if (String.IsNullOrEmpty(id))
                {
                    rootPage.NotifyUser("GetCustomerCollectionsIdAsync failed.", NotifyType.ErrorMessage);
                }
            }
        }