diff --git a/sdk/core/Azure.Core/src/Pipeline/HttpHeader.cs b/sdk/core/Azure.Core/src/Pipeline/HttpHeader.cs index 52a5dc189ee90..ee01cfe537286 100644 --- a/sdk/core/Azure.Core/src/Pipeline/HttpHeader.cs +++ b/sdk/core/Azure.Core/src/Pipeline/HttpHeader.cs @@ -62,10 +62,12 @@ public static class Common { static readonly string s_applicationJson = "application/json"; static readonly string s_applicationOctetStream = "application/octet-stream"; + static readonly string s_applicationFormUrlEncoded = "application/x-www-form-urlencoded"; public static readonly HttpHeader JsonContentType = new HttpHeader(Names.ContentType, s_applicationJson); public static readonly HttpHeader JsonAccept = new HttpHeader(Names.Accept, s_applicationJson); public static readonly HttpHeader OctetStreamContentType = new HttpHeader(Names.ContentType, s_applicationOctetStream); + public static readonly HttpHeader FormUrlEncodedContentType = new HttpHeader(Names.ContentType, s_applicationFormUrlEncoded); } } } diff --git a/sdk/identity/Azure.Identity/src/IdentityClient.cs b/sdk/identity/Azure.Identity/src/IdentityClient.cs index c61aef85f238f..53bfee83ebecf 100644 --- a/sdk/identity/Azure.Identity/src/IdentityClient.cs +++ b/sdk/identity/Azure.Identity/src/IdentityClient.cs @@ -8,6 +8,7 @@ using System.Buffers; using System.Collections.Generic; using System.IO; +using System.Net.Http; using System.Runtime.CompilerServices; using System.Security.Cryptography; using System.Security.Cryptography.X509Certificates; @@ -171,7 +172,7 @@ private Request CreateClientSecretAuthRequest(string tenantId, string clientId, request.Method = HttpPipelineMethod.Post; - request.Headers.SetValue("Content-Type", "application/x-www-form-urlencoded"); + request.Headers.Add(HttpHeader.Common.FormUrlEncodedContentType); request.UriBuilder.Uri = _options.AuthorityHost; @@ -194,7 +195,7 @@ private Request CreateClientCertificateAuthRequest(string tenantId, string clien request.Method = HttpPipelineMethod.Post; - request.Headers.SetValue("Content-Type", "application/x-www-form-urlencoded"); + request.Headers.Add(HttpHeader.Common.FormUrlEncodedContentType); request.UriBuilder.Uri = _options.AuthorityHost;