---
title: "webView(_:didReceive:completionHandler:)"
framework: webkit
role: symbol
role_heading: Instance Method
path: "webkit/wknavigationdelegate/webview(_:didreceive:completionhandler:)"
---

# webView(_:didReceive:completionHandler:)

Asks the delegate to respond to an authentication challenge.

## Declaration

```swift
optional func webView(_ webView: WKWebView, didReceive challenge: URLAuthenticationChallenge, completionHandler: @escaping @MainActor @Sendable (URLSession.AuthChallengeDisposition, URLCredential?) -> Void)
```

```swift
optional func webView(_ webView: WKWebView, respondTo challenge: URLAuthenticationChallenge) async -> (URLSession.AuthChallengeDisposition, URLCredential?)
```

## Parameters

- `webView`: The web view that receives the authentication challenge.
- `challenge`: The authentication challenge.
- `completionHandler`: A completion handler block to execute with the response. This handler has no return value and takes the following parameters:

## Mentioned in

Replacing UIWebView in your app

## Discussion

Discussion If you don’t implement this method, the web view responds to the authentication challenge with the URLSession.AuthChallengeDisposition.rejectProtectionSpace disposition.

## See Also

### Responding to authentication challenges

- [webView(_:authenticationChallenge:shouldAllowDeprecatedTLS:)](webkit/wknavigationdelegate/webview(_:authenticationchallenge:shouldallowdeprecatedtls:).md)
