<!--
{
  "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/URLAuthenticationChallengeSender/use(_:for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(pl)NSURLAuthenticationChallengeSender(im)useCredential:forAuthenticationChallenge:"
  },
  "title" : "use(_:for:)"
}
-->

# use(_:for:)

Attempt to use a given credential for a given authentication challenge.

```
func use(_ credential: URLCredential, for challenge: URLAuthenticationChallenge)
```

## Parameters

`credential`

The credential to use for authentication.

`challenge`

The challenge for which to use `credential`.

## Discussion

This method has no effect if it is called with an authentication challenge that has already been handled.

---

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)