Had to switch over to using Walmart's new oAuth-based authentication to generate an access token for integration into their Seller Center API. Had to piece together information from a few web sources so figured would post our request code here in case anyone else had to do the same.
string uri = "https://marketplace.walmartapis.com/v3/token";
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", Convert.ToBase64String(Encoding.ASCII.GetBytes(CLIENT_ID + ":" + CLIENT_SECRET)));
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
client.DefaultRequestHeaders.Add("WM_SVC.NAME", "Walmart Marketplace");
client.DefaultRequestHeaders.Add("WM_QOS.CORRELATION_ID", System.Guid.NewGuid().ToString()); //any random ID
client.DefaultRequestHeaders.Add("WM_SVC.VERSION", "1.0.0");
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, uri);
List<KeyValuePair<string, string>> lstKVs = new List<KeyValuePair<string, string>>();
lstKVs.Add(new KeyValuePair<string, string>("grant_type", "client_credentials"));
request.Content = new FormUrlEncodedContent(lstKVs);
request.Content.Headers.ContentType = new MediaTypeHeaderValue("application/x-www-form-urlencoded");
e851e6eb-ba7c-4394-8efa-5dfc8ff6afd9|5|2.6|27604f05-86ad-47ef-9e05-950bb762570c
Tags :