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

# download(_:didReceive:completionHandler:)

Asks the delegate to respond to an authentication challenge.

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

## Parameters

`download`

The download that received the authentication challenge.

`challenge`

The authentication challenge.

`completionHandler`

A closure you must invoke to respond to the authentication challenge. Provide the closure with a disposition that describes how to respond to the authorization challenge, and optional credentials.

## Discussion

Determine how to respond to the authentication challenge in this method. Then invoke `completionHandler` with a disposition that describes how to respond to the authorization challenge, and optional credentials.

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

---

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)