<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.2.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/URLProtocolClient/urlProtocol(_:didReceive:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(pl)NSURLProtocolClient(im)URLProtocol:didReceiveAuthenticationChallenge:"
  },
  "title" : "urlProtocol(_:didReceive:)"
}
-->

# urlProtocol(_:didReceive:)

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

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

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.

---

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)