diff --git a/Directory.Build.props b/Directory.Build.props
index d42d2900e..72d55c8dc 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -66,6 +66,14 @@
true
+
+ true
+ true
+ true
+ true
+ true
+
+
$(IsPackable)
diff --git a/samples/Mvc.Client/Mvc.Client.csproj b/samples/Mvc.Client/Mvc.Client.csproj
index 1c64264a8..bd251bdeb 100644
--- a/samples/Mvc.Client/Mvc.Client.csproj
+++ b/samples/Mvc.Client/Mvc.Client.csproj
@@ -2,7 +2,7 @@
false
- $(DefaultNetCoreTargetFramework)
+ $(DefaultNetCoreTargetFramework)
AspNet.Security.OAuth.Providers.Mvc.Client
diff --git a/src/AspNet.Security.OAuth.Trovo/TrovoAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Trovo/TrovoAuthenticationHandler.cs
index b9a57904b..8e2ab83b0 100644
--- a/src/AspNet.Security.OAuth.Trovo/TrovoAuthenticationHandler.cs
+++ b/src/AspNet.Security.OAuth.Trovo/TrovoAuthenticationHandler.cs
@@ -11,6 +11,7 @@
using System.Text;
using System.Text.Encodings.Web;
using System.Text.Json;
+using System.Text.Json.Serialization;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
@@ -72,11 +73,13 @@ protected override async Task ExchangeCodeAsync([NotNull] OA
context.Properties.Items.Remove(OAuthConstants.CodeVerifierKey);
}
+ var content = JsonSerializer.Serialize(tokenRequestParameters, AppJsonSerializerContext.Default.DictionaryStringString);
+
using var request = new HttpRequestMessage(HttpMethod.Post, Options.TokenEndpoint);
request.Headers.Add(ClientIdHeaderName, Options.ClientId);
request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(MediaTypeNames.Application.Json));
- request.Content = new StringContent(JsonSerializer.Serialize(tokenRequestParameters), Encoding.UTF8, MediaTypeNames.Application.Json);
+ request.Content = new StringContent(content, Encoding.UTF8, MediaTypeNames.Application.Json);
using var response = await Backchannel.SendAsync(request, Context.RequestAborted);
@@ -91,6 +94,11 @@ protected override async Task ExchangeCodeAsync([NotNull] OA
return OAuthTokenResponse.Success(payload);
}
+ [JsonSerializable(typeof(Dictionary))]
+ internal sealed partial class AppJsonSerializerContext : JsonSerializerContext
+ {
+ }
+
private static partial class Log
{
internal static async Task UserProfileErrorAsync(ILogger logger, HttpResponseMessage response, CancellationToken cancellationToken)
diff --git a/src/AspNet.Security.OAuth.Yammer/YammerAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Yammer/YammerAuthenticationHandler.cs
index 27ca04e79..f62700479 100644
--- a/src/AspNet.Security.OAuth.Yammer/YammerAuthenticationHandler.cs
+++ b/src/AspNet.Security.OAuth.Yammer/YammerAuthenticationHandler.cs
@@ -9,6 +9,7 @@
using System.Security.Claims;
using System.Text.Encodings.Web;
using System.Text.Json;
+using System.Text.Json.Serialization;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
@@ -85,15 +86,32 @@ protected override async Task ExchangeCodeAsync([NotNull] OA
using var payload = JsonDocument.Parse(await response.Content.ReadAsStringAsync(Context.RequestAborted));
var accessToken = payload.RootElement.GetProperty("access_token").GetString("token");
- var token = new
+ var token = new OAuthToken()
{
- access_token = accessToken,
- token_type = string.Empty,
- refresh_token = string.Empty,
- expires_in = string.Empty,
+ AccessToken = accessToken,
};
- return OAuthTokenResponse.Success(JsonSerializer.SerializeToDocument(token));
+ return OAuthTokenResponse.Success(JsonSerializer.SerializeToDocument(token, AppJsonSerializerContext.Default.OAuthToken));
+ }
+
+ [JsonSerializable(typeof(OAuthToken))]
+ internal sealed partial class AppJsonSerializerContext : JsonSerializerContext
+ {
+ }
+
+ internal sealed class OAuthToken
+ {
+ [JsonPropertyName("access_token")]
+ public string? AccessToken { get; set; }
+
+ [JsonPropertyName("token_type")]
+ public string TokenType { get; set; } = string.Empty;
+
+ [JsonPropertyName("refresh_token")]
+ public string RefreshToken { get; set; } = string.Empty;
+
+ [JsonPropertyName("expires_in")]
+ public string ExpiresIn { get; set; } = string.Empty;
}
private static partial class Log