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

# download(_:didReceive:completionHandler:)

Asks the delegate to respond to an authentication challenge.

## Declaration

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

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

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

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 URLSession.AuthChallengeDisposition.rejectProtectionSpace.

## See Also

### Responding to Authorization Challenges

- [WKDownload.RedirectPolicy](webkit/wkdownload/redirectpolicy.md)
