<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.4.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CFNetwork",
  "identifier" : "/documentation/CFNetwork/CFHTTPMessageApplyCredentialDictionary(_:_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "CFNetwork"
    ],
    "preciseIdentifier" : "c:@F@CFHTTPMessageApplyCredentialDictionary"
  },
  "title" : "CFHTTPMessageApplyCredentialDictionary(_:_:_:_:)"
}
-->

# CFHTTPMessageApplyCredentialDictionary(_:_:_:_:)

Use a dictionary containing authentication credentials to perform the authentication method specified by a `CFHTTPAuthentication` object.

```
func CFHTTPMessageApplyCredentialDictionary(_ request: CFHTTPMessage, _ auth: CFHTTPAuthentication, _ dict: CFDictionary, _ error: UnsafeMutablePointer<CFStreamError>?) -> Bool
```

## Parameters

`request`

The request for which the authentication method is to be performed.

`auth`

A `CFHTTPAuthentication` object specifying the authentication method to perform.

`dict`

A dictionary containing authentication credentials to be applied to the request. For information on the keys in this dictionary, see [`CFHTTPAuthentication`](/documentation/CFNetwork/CFHTTPAuthentication).

`error`

If an error occurs, upon return contains a <doc://com.apple.documentation/documentation/CoreFoundation/CFStreamError> object that describes the error and the error’s domain. Pass `NULL` if you don’t want to receive error information.

## Return Value

`TRUE` if the authentication was successful, otherwise, `FALSE`.

## Discussion

This function performs the authentication method specified by `auth` on behalf of the request specified by `request` using the credentials contained in the dictionary specified by `dict`. The dictionary must contain values for the `kCFHTTPAuthenticationUsername` and `kCFHTTPAuthenticationPassword` keys. If [`CFHTTPAuthenticationRequiresAccountDomain(_:)`](/documentation/CFNetwork/CFHTTPAuthenticationRequiresAccountDomain(_:)) returns `TRUE` for `auth`, the dictionary must also contain a value for the `kCFHTTPAuthenticationAccountDomain` key.

### Special Considerations

This function is thread safe as long as another thread does not alter the same `CFHTTPAuthentication` object at the same time.

---

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)