Reputation: 37
I have a project that uses the WebView2
control to access various sites that all require Authorization (some require Basic, others OAuth). To provide a generic solution I deal with all Authorization requirements in the CoreWebView2.WebResourceRequested
event and this works just fine by adding the required Auth via the Request.Headers.SetHeader
for all Auth types, this way I don't need to know which Auth type is needed.
I have hit an issue with 1 of the Basic Auth sites (not all of them). The initial call works as expected in the auth flow and I see 200 response. This is an example:
example.com/service/id=1 (response:200)
example.com/service/id=1?offset=winter (response:200)
example.com/service/id=1 (response:302, location:example.com/service/id=1)
example.com/service/id=1 (response:401)
With my code in debug I can see that my code to apply the Headers is being hit on each call.
One thing I've tried which is odd, I've added the event handler for Basic Auth CoreWebView2.BasicAuthenticationRequested
and when the re-direct happens, this event is raised. Now the odd bit is, if I set the Response.UserName
or Response.Password
to anything (not blank), the Auth works and the page I want is displayed.
I think this is being caused by the re-direct, but I can't figure if this is possibly a bug in the WebView2
control. Any help would be great.
Upvotes: 0
Views: 48