Skip to content

Commit a611bcb

Browse files
authored
Merge pull request #425 from serverlessworkflow/fix-oauth2-request
Fixed the OAuth2TokenManager, which was not properly checking against unconfigured token request parameters
2 parents fc4477c + b60e548 commit a611bcb

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/core/Synapse.Core.Infrastructure/Services/OAuth2TokenManager.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,11 @@ public virtual async Task<OAuth2Token> GetTokenAsync(OAuth2AuthenticationSchemeD
127127
properties["grant_type"] = "refresh_token";
128128
properties["refresh_token"] = token.RefreshToken;
129129
}
130-
using var content = configuration.Request.Encoding switch
130+
using var content = configuration.Request?.Encoding switch
131131
{
132-
OAuth2RequestEncoding.FormUrl => (HttpContent)new FormUrlEncodedContent(properties),
132+
null or OAuth2RequestEncoding.FormUrl => (HttpContent)new FormUrlEncodedContent(properties),
133133
OAuth2RequestEncoding.Json => new StringContent(this.JsonSerializer.SerializeToText(properties), Encoding.UTF8, MediaTypeNames.Application.Json),
134-
_ => throw new NotSupportedException($"The specified OAUTH2 request encoding '{configuration.Request.Encoding}' is not supported")
134+
_ => throw new NotSupportedException($"The specified OAUTH2 request encoding '{configuration.Request?.Encoding ?? OAuth2RequestEncoding.FormUrl}' is not supported")
135135
};
136136
using var request = new HttpRequestMessage(HttpMethod.Post, tokenEndpoint) { Content = content };
137137
if (configuration.Client?.Authentication == OAuth2ClientAuthenticationMethod.Basic)

0 commit comments

Comments
 (0)