IdentityModel.OidcClient
IdentityModel.OidcClient copied to clipboard
[iOS][Xamarin] Crash for OidcClient 4.0 in iOS
Hi there, We use OidcClient 4.0 on Xamarin.iOS and when preparing the login, the OidcClient returns with an Exception that looks like the following:
The type initializer for 'System.Text.Json.JsonSerializer' threw an exception.
Inner Exception:
Attempting to JIT compile method 'int System.Text.Json.JsonWriterHelper:NeedsEscaping (System.ReadOnlySpan1<byte>,System.Text.Encodings.Web.JavaScriptEncoder)' while running in aot-only mode. See https://docs.microsoft.com/xamarin/ios/internals/limitations for more information.
Stack Trace:
at System.Text.Json.JsonEncodedText.EncodeHelper (System.ReadOnlySpan1[T] utf8Value, System.Text.Encodings.Web.JavaScriptEncoder encoder) [0x00000] in <cb68364b029e41c3bf425990b94c94d9>:0 at System.Text.Json.JsonEncodedText.TranscodeAndEncode (System.ReadOnlySpan1[T] value, System.Text.Encodings.Web.JavaScriptEncoder encoder) [0x00033] in <cb68364b029e41c3bf425990b94c94d9>:0 at System.Text.Json.JsonEncodedText.Encode (System.ReadOnlySpan1[T] value, System.Text.Encodings.Web.JavaScriptEncoder encoder) [0x00014] in <cb68364b029e41c3bf425990b94c94d9>:0 at System.Text.Json.JsonEncodedText.Encode (System.String value, System.Text.Encodings.Web.JavaScriptEncoder encoder) [0x00014] in <cb68364b029e41c3bf425990b94c94d9>:0 at System.Text.Json.JsonSerializer..cctor () [0x00042] in <cb68364b029e41c3bf425990b94c94d9>:0
We created our client like this:
var options = new OidcClientOptions
{
Authority = idsUrl,
ClientId = IdS_ClientId,
Scope = IdS_Scope,
RedirectUri = IdS_RedirectUrl,
Policy =
{
Discovery =
{
AuthorityValidationStrategy = new StringComparisonAuthorityValidationStrategy(StringComparison.OrdinalIgnoreCase),
RequireHttps = false
}
}
};
var _client = new OidcClient(options);
_client.PrepareLoginAsync (new IdentityModel.Client.Parameters { new KeyValuePair<string, string> ("prompt", "login") }, _tokenSource.Token);
It worked with 3.1.2. Do you know what to do about this? Thanks a lot in advance! Best Daniel
Sounds familiar - check the issue tracker. Something around package incompatibilities. Also have you tried v5?
Hi :) Thanks! Which Issue Tracker are you referring to? Github or a different one? v5 is for us no option, yet, as our other dependencies use 4.0, but we can try.
Hello there, i have a very similiar problem with System.Text.Json only on Xamarin.iOS, May both issues be related to this triggered by this issue ? My problem is exactly the one posted last year.
The workaround apparently it's not working anymore?! I couldn't make it work at least. (Running on VS2022, latest Xamarin.iOS, IdentityModel.OidcClient 5.0.0)