IdentityModel / IdentityModel.OidcClient.Old

OpenID Connect Client Library for Native Applications
Other
38 stars 17 forks source link

RefreshTokenAsync causes NullReferenceException #62

Closed filoe closed 6 years ago

filoe commented 6 years ago

Hello!

First of all thanks for the usefull library!

I've got the following problem. I am on v2.2.0. Running the app on a Xamarin.Forms application (Android in particular). Having netstandard 1.4 and monoandroid v8. Upgrading to v2.3.0(or 2.4.0) let the application crash:

12-24 01:33:18.266 D/Mono ( 7712): Assembly Loader probing location: 'System.Runtime.CompilerServices.Unsafe'. 12-24 01:33:18.266 F/monodroid-assembly( 7712): Could not load assembly 'System.Runtime.CompilerServices.Unsafe' during startup registration. 12-24 01:33:18.266 F/monodroid-assembly( 7712): This might be due to an invalid debug installation.

Running v2.2.0: Options are initialized with:

_client = new OidcClient(BuildOptions());
private OidcClientOptions BuildOptions()
            => new OidcClientOptions
            {
                    Authority = _configuration.IdentityEndpoint,
                    ClientId = _configuration.ClientId,
                    ClientSecret = _configuration.ClientSecret,
                    RedirectUri = _configuration.IdentityCallback,
                    ResponseMode = OidcClientOptions.AuthorizeResponseMode.Redirect,
                    Scope = "openid profile API CMD PA offline_access",
                    Browser = _browser,
                    Policy = new Policy
                    {
                        Discovery = new DiscoveryPolicy
                        {
                            RequireHttps = _configuration.DevelopmentStage == DevelopmentStage.Production
                        }
                    }
                };

Calling the client: var refreshTokenResult = await _client.RefreshTokenAsync(Settings.RefreshToken);

Causes a NullReferenceException: For me it seems like the ProviderInformation won't load...

NullReferenceException occurs here:

at IdentityModel.OidcClient.Infrastructure.TokenClientFactory.Create (IdentityModel.OidcClient.OidcClientOptions options) [0x00039] in <856304cc89934c4a95195a3f89a8d589>:0 at IdentityModel.OidcClient.OidcClient+d12.MoveNext () [0x0002b] in <856304cc89934c4a95195a3f89a8d589>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <657aa8fea4454dc898a9e5f379c58734>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <657aa8fea4454dc898a9e5f379c58734>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <657aa8fea4454dc898a9e5f379c58734>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <657aa8fea4454dc898a9e5f379c58734>:0 at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0 at MobileApp.Services.Authentication.AuthenticationService+d13.MoveNext () [0x0004a] in ... --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <657aa8fea4454dc898a9e5f379c58734>:0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <657aa8fea4454dc898a9e5f379c58734>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <657aa8fea4454dc898a9e5f379c58734>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <657aa8fea4454dc898a9e5f379c58734>:0 at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0 at MobileApp.Services.Authentication.AuthenticationService+d__9.MoveNext () [0x0004c] in ...

leastprivilege commented 6 years ago

Could you please debug with the latest version?

filoe commented 6 years ago

I am sorry. I am on the wrong github project. Anyhow, >=2.3.0 let my xamarin app crash on startup.

Am 24.12.2017 um 01:58 schrieb Dominick Baier notifications@github.com:

Could you please debug with the latest version?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.

leastprivilege commented 6 years ago

Well . then we need to find the reason for that first. I don't have an Android test environment - so if you need this to be fixed, you need to help.

leastprivilege commented 6 years ago

please move to OidcClient2