KeyCloak integrated with Azure Ad creates a new code challenge when I login via Azure Ad

In my application, I create a code challenge and verifier and pass it to the Authorize endpoint in keycloak. I have added Azure Ad as an identityProvider. I am using the Auth Code with PKCE flow

The problem is that when I click on the login via azure ad button(added through the identity Provider), it creates a new code challenge, So when I call the token endpoint I always get an error saying “Code verfier doesnt match”. Do I need to write code to handle the redirect to Azure Ad as well?

ErrorMessage : "The Code_Verifier does not match the code_challenge supplied in the authorization "

I am trying to integrate keycloak with Azure ad in a WPF app.

Code

I am new to WPF and Keycloak, So please let me know if I am missing anything.