I am following the example to authenticate a user by using this sample:
https://github.com/IdentityModel/IdentityModel.OidcClient.Samples/tree/master/XamarinForms
I have the login working, it authenticates and closes the ChromeTabBrowser and redirects back to my app screen because of the RedirectURI setting, but this sample online doesn't have an example for the Logoff functionality. How would I do the same, Logoff, and then have it close the ChromeTabBrowser and redirect back to my app, I have set the same URI I am using for login, to the PostLogoutRedirectURI property in the OidcClientOptions, but no luck.
public static OidcClientOptions SetAuthOptionsPostLogout()
{
var browser = DependencyService.Get();
return new OidcClientOptions
{
Authority = GlobalSetting.Instance.AuthAuthorityURI,
ClientId = GlobalSetting.Instance.AuthClientID,
Scope = GlobalSetting.Instance.AuthScope,
RedirectUri = GlobalSetting.Instance.AuthReturnURI,
PostLogoutRedirectUri = GlobalSetting.Instance.AuthReturnURI,
Browser = browser,
ResponseMode = OidcClientOptions.AuthorizeResponseMode.Redirect
};
}
and my call to logout is:
public ICommand Logout => new Command(async () =>
{
try
{
LoadingMessage = "Logging Off...";
IsBusy = true;
var options = AuthService.SetAuthOptionsPostLogout();
Client = new OidcClient(options);
await Client.LogoutAsync();
//DELETE OTHER SETTINGS HERE
IsBusy = false;
await _Navigation.PushAsync(new Login());
}
catch (Exception ex)
{
IsBusy = false;
await ex.TrackAndShowAlert("VM", "Logout");
}
});
The authentication service logs me off, but that window never closes, so in the app, the spinning "Logging Off..." is still active awaiting the call.