时区更改后授权码立即过期

Authorization code got immediately expired after time zone changed

我正在为 OpenId 服务器使用 OpenIdDict 库。当我处于 EST (-5h) 时区时,一切都运行良好。但是当我转到 UTC+03 时区时,我不断收到错误消息:

OpenIddict.Server.Internal.OpenIddictServerHandler: Error: The token request was rejected because the authorization code or the refresh token was expired.

完全相同的代码。当我调用令牌交换端点时发生错误。我检查了数据库,那里的所有值似乎都是正确的 UTC 值。

我发现错误发生在 AspNet.Security.OpenIdConnect.Server\src\AspNet.Security.OpenIdConnect.Server\OpenIdConnectServerHandler.Exchange.cs。但我不确定如何调试它。

错误的原因是 Oracle MySql 驱动程序 https://bugs.mysql.com/bug.php?id=92367. If you faced the same problem you can find pretty good explanation and workaround here: https://github.com/openiddict/openiddict-core/issues/1097#issuecomment-698374105 中的一个很老的问题。 目前最好的解决方案似乎是切换到 Pomelo 驱动程序:https://www.nuget.org/packages/Pomelo.EntityFrameworkCore.MySQL