From 2cc49d871e1bcbab8a405d42df0f409fc2779ee4 Mon Sep 17 00:00:00 2001 From: Gehongyan Date: Tue, 25 Feb 2025 14:07:12 +0800 Subject: [PATCH] Add Alibaba Cloud (Aliyun) to the list of supported providers --- ...ctClientWebIntegrationHandlers.Exchange.cs | 20 +++++++++--------- ...penIddictClientWebIntegrationProviders.xml | 21 +++++++++++++++++++ 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Exchange.cs b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Exchange.cs index 0e2dcab11..a8c9211f1 100644 --- a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Exchange.cs +++ b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationHandlers.Exchange.cs @@ -357,23 +357,23 @@ public ValueTask HandleAsync(ExtractTokenResponseContext context) context.Response.RefreshToken = null; } + // Note: Alibaba Cloud and Exact Online returns a non-standard "expires_in" + // parameter formatted as a string instead of a numeric type. + if (context.Registration.ProviderType is ProviderTypes.AlibabaCloud or ProviderTypes.ExactOnline && + long.TryParse((string?) context.Response[Parameters.ExpiresIn], + NumberStyles.Integer, CultureInfo.InvariantCulture, out long value)) + { + context.Response.ExpiresIn = value; + } + // Note: Deezer doesn't return a standard "expires_in" parameter // but returns an equivalent "expires" integer parameter instead. - if (context.Registration.ProviderType is ProviderTypes.Deezer) + else if (context.Registration.ProviderType is ProviderTypes.Deezer) { context.Response[Parameters.ExpiresIn] = context.Response["expires"]; context.Response["expires"] = null; } - // Note: Exact Online returns a non-standard "expires_in" - // parameter formatted as a string instead of a numeric type. - else if (context.Registration.ProviderType is ProviderTypes.ExactOnline && - long.TryParse((string?) context.Response[Parameters.ExpiresIn], - NumberStyles.Integer, CultureInfo.InvariantCulture, out long value)) - { - context.Response.ExpiresIn = value; - } - // Note: Huawei returns a non-standard "error" parameter as a numeric value, which is not allowed // by OpenIddict (that requires a string). Huawei also returns a non-standard "sub_error" parameter // that contains additional error information, with which the error code can demonstrate a specific diff --git a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xml b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xml index 1749cc5d6..b599228df 100644 --- a/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xml +++ b/src/OpenIddict.Client.WebIntegration/OpenIddictClientWebIntegrationProviders.xml @@ -74,6 +74,27 @@ + + + + + + + + + +