---
title: "use(_:for:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/urlauthenticationchallengesender/use(_:for:)"
---

# use(_:for:)

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

## Declaration

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

## Parameters

- `credential`: The credential to use for authentication.
- `challenge`: The challenge for which to use credential.

## Discussion

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

## See Also

### Protocol Methods

- [cancel(_:)](foundation/urlauthenticationchallengesender/cancel(_:).md)
- [continueWithoutCredential(for:)](foundation/urlauthenticationchallengesender/continuewithoutcredential(for:).md)
- [performDefaultHandling(for:)](foundation/urlauthenticationchallengesender/performdefaulthandling(for:).md)
- [rejectProtectionSpaceAndContinue(with:)](foundation/urlauthenticationchallengesender/rejectprotectionspaceandcontinue(with:).md)
