コード例 #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);
        }
コード例 #2
0
        public static string Stringify(this PostActionData data)
        {
            JsonObject jsonObject = new JsonObject();

            jsonObject.Add("AuthData", data.AuthData.ToJson());
            jsonObject.Add("CollectionStoreID", JsonValue.CreateStringValue(data.CollectionStoreID));
            jsonObject.Add("PurchaseStoreID", JsonValue.CreateStringValue(data.PurchaseStoreID));
            jsonObject.Add("UID", JsonValue.CreateStringValue(data.UID));

            return(jsonObject.Stringify());
        }
コード例 #3
0
        public async Task <string> Post([FromBody] PostActionData value)
        {
            var purchases = await GetSubscriptionsForUser(value.AuthData.Auth, value.PurchaseStoreID);

            var collection = await QueryOfProduct(value.AuthData.Auth, value.CollectionStoreID, value.UID);

            var renewCollection = await RenewMSStoreID(AuthType.Collection, value.AuthData.Auth, value.CollectionStoreID);

            var renewPurchase = await RenewMSStoreID(AuthType.Purchase, value.AuthData.Auth, value.PurchaseStoreID);

            string responseContent = $"{purchases}\r\n{collection}\r\n{renewCollection}\r\n{renewPurchase}";

            return(responseContent);
        }