---
title: "urlProtocol(_:didReceive:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/urlprotocolclient/urlprotocol(_:didreceive:)"
---

# urlProtocol(_:didReceive:)

Tells the client that the URL Loading System received an authentication challenge.

## Declaration

```swift
func urlProtocol(_ protocol: URLProtocol, didReceive challenge: URLAuthenticationChallenge)
```

## Parameters

- `protocol`: The URL protocol object sending the message.
- `challenge`: The authentication challenge that has been received.

## Discussion

Discussion The protocol client guarantees that it will answer the request on the same thread that called this method. The client may add a default credential to the challenge it issues to the connection delegate, if protocol did not provide one.

## See Also

### Handling authentication challenges

- [urlProtocol(_:didCancel:)](foundation/urlprotocolclient/urlprotocol(_:didcancel:).md)
