I am having a .Net Desktop based application (WinForm - .Net framework 4.8). As the backend services are using OAuth2.0, I required to generate accessToken and pass it as header.
Since it's desktop app I am using Authorization Code Grant type which requires redirect URL. My implementation is using library "IdentityModel.OidcClient" which requires "Browser" parameter to redirect. Here is the sample. https://github.com/IdentityModel/IdentityModel.OidcClient.Samples/tree/main/WinFormsWebView2
I have exact same implementation as per the above sample which works overall however, it takes around 8 secs to get AccessToken which is too much.
Around 60% of time is going in my navigation code (callback happens from OIDCClient lib) where it redirects to my redirect URl and returns "authorization code" to library. I am suspecting use of full web browser / webview2 control to get access token is overhead here.
Is there any other option where without WebBrowser control I can get access token with Authorization Code as a grant type ?
If not how to improve performance as this much time is nearly not acceptable while opening of application as well as at every one hour when token gets expired.
Thanks, Manoj