<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.10.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "WebKit",
  "identifier" : "/documentation/WebKit/WKNavigationDelegate/webView(_:didReceive:completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "WebKit"
    ],
    "preciseIdentifier" : "c:objc(pl)WKNavigationDelegate(im)webView:didReceiveAuthenticationChallenge:completionHandler:"
  },
  "title" : "webView(_:didReceive:completionHandler:)"
}
-->

# webView(_:didReceive:completionHandler:)

Asks the delegate to respond to an authentication challenge.

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

## 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:

- disposition: The option to use to handle the challenge. For a list of options, see <doc://com.apple.documentation/documentation/Foundation/URLSession/AuthChallengeDisposition>.
- credential: The credential to use for authentication when the `disposition` parameter contains the value <doc://com.apple.documentation/documentation/Foundation/URLSession/AuthChallengeDisposition/useCredential>. Specify `nil` to continue without a credential.

## Discussion

If you don’t implement this method, the web view responds to the authentication challenge with the <doc://com.apple.documentation/documentation/Foundation/URLSession/AuthChallengeDisposition/rejectProtectionSpace> disposition.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)