diff --git a/src/OpenIddict.Abstractions/OpenIddictConstants.cs b/src/OpenIddict.Abstractions/OpenIddictConstants.cs index a0c9c076..7d98d584 100644 --- a/src/OpenIddict.Abstractions/OpenIddictConstants.cs +++ b/src/OpenIddict.Abstractions/OpenIddictConstants.cs @@ -547,6 +547,7 @@ public static class OpenIddictConstants public const string Phone = "phone"; public const string Profile = "profile"; public const string Roles = "roles"; + public const string Name = "name"; } public static class Separators diff --git a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Userinfo.cs b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Userinfo.cs index 7d3e3f63..d46f8b17 100644 --- a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Userinfo.cs +++ b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Userinfo.cs @@ -512,6 +512,18 @@ public static partial class OpenIddictClientWebIntegrationHandlers } } + // Note: Apple returns a non-standard "name" claim formatted as a JSON object. + else if (context.Registration.ProviderType is ProviderTypes.Apple) + { + var name = context.Response[Claims.Name]; + if (name is not null) + { + context.Response[Claims.Name] = $"{name?["firstName"]} {name?["lastName"]}"; + context.Response[Claims.FamilyName] = name?["lastName"]; + context.Response[Claims.GivenName] = name?["firstName"]; + } + } + return ValueTask.CompletedTask; } } diff --git a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.cs b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.cs index 346aaaff..24a712e3 100644 --- a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.cs +++ b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.cs @@ -1750,7 +1750,7 @@ public static partial class OpenIddictClientWebIntegrationHandlers context.ResponseMode = context.Registration.ProviderType switch { // Note: Apple requires using form_post when the "email" or "name" scopes are requested. - ProviderTypes.Apple when context.Scopes.Contains(Scopes.Email) || context.Scopes.Contains("name") + ProviderTypes.Apple when context.Scopes.Contains(Scopes.Email) || context.Scopes.Contains(Scopes.Name) => ResponseModes.FormPost, _ => context.ResponseMode