@@ -51,9 +51,9 @@ The developer can provide the authentication credentials on behalf of the user w
5151 args->GetDeferral(&deferral);
5252 ShowCustomLoginUI().then([web_auth_args, deferral](LPCWSTR userName, LPCWSTR password) {
5353 wil::com_ptr<ICoreWebView2WebAuthenticationResponse> webAuthenticationResponse;
54- webviewEnvironment->CreateWebAuthenticationResponse(
55- userName, password, & webAuthenticationResponse);
56- args->put_Response(webAuthenticationResponse.get() );
54+ args->get_Response(&webAuthenticationResponse);
55+ webAuthenticationResponse->put_UserName(userName );
56+ webAuthenticationResponse->put_Password(password );
5757 deferral->Complete();
5858 }
5959
@@ -68,9 +68,8 @@ webView.CoreWebView2.WebAuthenticationRequested += delegate (object sender, Core
6868{
6969 CoreWebView2Deferral deferral = args.GetDeferral();
7070 Credential credential = await ShowCustomLoginUIAsync();
71- CoreWebView2WebAuthenticationResponse response = _coreWebView2Environment.CreateWebAuthenticationResponse(
72- credential.username, credential.password);
73- args.Response = response;
71+ args.Response.UserName = credential.UserName;
72+ args.Response.Password = credential.Password;
7473 deferral.Complete();
7574};
7675```
@@ -152,7 +151,7 @@ interface ICoreWebView2_4 : ICoreWebView2_3
152151 ///
153152 /// The host can provide a response with credentials for the authentication or
154153 /// cancel the request. If the host doesn't set the Cancel property to true or
155- /// set the Response property, then WebView2 will show the default
154+ /// populate the Response property, then WebView2 will show the default
156155 /// authorization challenge dialog prompt to the user.
157156 ///
158157 HRESULT add_WebAuthenticationRequested(
@@ -202,13 +201,12 @@ interface ICoreWebView2WebAuthenticationRequestedEventArgs : IUnknown
202201 /// The authorization challenge string
203202 [propget] HRESULT Challenge([out, retval] LPWSTR* challenge);
204203
205- /// Response to the authentication request with credentials.
204+ /// Response to the authentication request with credentials. This object will be populated by the app
205+ /// if the host would like to provide authentication credentials.
206206 [propget] HRESULT Response([out, retval] ICoreWebView2WebAuthenticationResponse** response);
207- /// Set the Response property.
208- [propput] HRESULT Response([in] ICoreWebView2WebAuthenticationResponse* response);
209-
207+
210208 /// Cancel the authentication request. False by default.
211- /// If set to true, Response will be ignored.
209+ /// If set to true, Response set will be ignored.
212210 [propget] HRESULT Cancel([out, retval] BOOL* cancel);
213211 /// Set the Cancel property.
214212 [propput] HRESULT Cancel([in] BOOL cancel);
@@ -218,33 +216,11 @@ interface ICoreWebView2WebAuthenticationRequestedEventArgs : IUnknown
218216 HRESULT GetDeferral([out, retval] ICoreWebView2Deferral** deferral);
219217}
220218
221- [uuid(0cec3e32-36aa-4859-9bbe-f9c116ad4721), object, pointer_default(unique)]
222- interface ICoreWebView2Environment3 : ICoreWebView2Environment2
223- {
224- /// Create a WebAuthenticationResponse object used to provide credentials for
225- /// WebAuthenticationRequested event
226- HRESULT CreateWebAuthenticationResponse(
227- [in] LPCWSTR userName,
228- [in] LPCWSTR password,
229- [out, retval] ICoreWebView2WebAuthenticationResponse** response);
230- }
231-
232219```
233220
234221``` c#
235222namespace Microsoft .Web .WebView2 .Core
236223{
237- runtimeclass CoreWebView2Environment
238- {
239- ...
240-
241- /// Create a WebAuthenticationResponse object used to provide credentials for
242- /// WebAuthenticationRequested event
243- public CoreWebView2WebAuthenticationResponse CreateWebAuthenticationResponse(
244- String userName,
245- String password);
246- }
247-
248224 /// Event args for the WebAuthorizationRequested event. Will contain the
249225 /// request that led to the HTTP authorization challenge, the challenge
250226 /// and allows the host to provide authentication response or cancel the request.
@@ -260,8 +236,9 @@ namespace Microsoft.Web.WebView2.Core
260236 /// If set to true, Response will be ignored.
261237 bool Cancel { get ; set ; };
262238
263- /// Response to the authentication request with credentials.
264- CoreWebView2WebAuthenticationResponse Response { get ; set ; };
239+ /// Response to the authentication request with credentials. This object will be populated by the app
240+ /// if the host would like to provide authentication credentials.
241+ CoreWebView2WebAuthenticationResponse Response { get ; };
265242 }
266243
267244 /// Represents a Basic HTTP authentication response that contains a user name
@@ -283,7 +260,7 @@ namespace Microsoft.Web.WebView2.Core
283260 /// WebAuthenticationRequested event is raised when WebView encountered a Basic HTTP
284261 /// Authentication request.
285262 ///
286- /// The host can provide a response with credentials for the authentication or
263+ /// The host can populate the response object with credentials it wants to use for the authentication or
287264 /// cancel the request. If the host doesn't handle the event, WebView will show
288265 /// the authorization challenge dialog prompt to user.
289266 ///
0 commit comments