diff --git a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Userinfo.cs b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Userinfo.cs index 3af5c85e..9aeefeed 100644 --- a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Userinfo.cs +++ b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Userinfo.cs @@ -26,6 +26,7 @@ public static partial class OpenIddictClientWebIntegrationHandlers */ AttachRequestHeaders.Descriptor, AttachAccessTokenParameter.Descriptor, + AttachNonStandardParameters.Descriptor, /* * Userinfo response extraction: @@ -125,6 +126,41 @@ public static partial class OpenIddictClientWebIntegrationHandlers } } + /// + /// Contains the logic responsible for attaching non-standard + /// parameters to the request for the providers that require it. + /// + public sealed class AttachNonStandardParameters : IOpenIddictClientHandler + { + /// + /// Gets the default descriptor definition assigned to this handler. + /// + public static OpenIddictClientHandlerDescriptor Descriptor { get; } + = OpenIddictClientHandlerDescriptor.CreateBuilder() + .UseSingletonHandler() + .SetOrder(AttachQueryStringParameters.Descriptor.Order - 250) + .SetType(OpenIddictClientHandlerType.BuiltIn) + .Build(); + + /// + public ValueTask HandleAsync(PrepareUserinfoRequestContext context) + { + if (context is null) + { + throw new ArgumentNullException(nameof(context)); + } + + // ArcGIS Online doesn't support header-based content negotiation and requires using + // the non-standard "f" parameter to get back JSON responses instead of HTML pages. + if (context.Registration.ProviderName is Providers.ArcGisOnline) + { + context.Request["f"] = "json"; + } + + return default; + } + } + /// /// Contains the logic responsible for normalizing the returned content /// type of userinfo responses for the providers that require it. diff --git a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xml b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xml index 70eac24d..22288420 100644 --- a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xml +++ b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xml @@ -29,6 +29,30 @@ Description="The optional value used as the 'resource' parameter (e.g urn:microsoft:userinfo)" /> + + + + + + + + + + + + + + +