---
title: "CFHTTPAuthenticationCreateFromResponse(_:_:)"
framework: cfnetwork
role: symbol
role_heading: Function
path: "cfnetwork/cfhttpauthenticationcreatefromresponse(_:_:)"
---

# CFHTTPAuthenticationCreateFromResponse(_:_:)

Uses an authentication failure response to create a CFHTTPAuthentication object.

## Declaration

```swift
func CFHTTPAuthenticationCreateFromResponse(_ alloc: CFAllocator?, _ response: CFHTTPMessage) -> Unmanaged<CFHTTPAuthentication>
```

## Parameters

- `alloc`: The allocator to use to allocate memory for the new object. Pass NULL or kCFAllocatorDefault to use the current default allocator.
- `response`: Response indicating an authentication failure; usually a 401 or a 407 response.

## Return Value

Return Value CFHTTPAuthentication object that can be used for adding credentials to future requests. Ownership follows the The Create Rule.

## Discussion

Discussion This function uses a response containing authentication failure information to create a reference to a CFHTTPAuthentication object. You can use the object to add credentials to future requests. You can query the object to get the following information: whether it can be used and re-used to authenticate with its corresponding server [CFHTTPAuthenticationIsValid(_:_:)] the authentication method that will be used when it is used to perform an authentication [CFHTTPAuthenticationCopyMethod(_:)] whether it is associated with a particular CFHTTPMessageRef [CFHTTPAuthenticationAppliesToRequest(_:_:) whether a user name and a password will be required when it is used to perform an authentication [CFHTTPAuthenticationRequiresUserNameAndPassword(_:)] whether an account domain will be required when it is used to perform an authentication [CFHTTPAuthenticationRequiresAccountDomain(_:)] whether authentication requests should be sent one at a time to the corresponding server [CFHTTPAuthenticationRequiresOrderedRequests(_:)] the namespace (if any) that the domain uses to prompt for a name and password [CFHTTPAuthenticationCopyRealm(_:)] the domain URLs the instance applies to [CFHTTPAuthenticationCopyDomains(_:)] When you have determined what information will be needed to perform the authentication and accumulated that information, call CFHTTPMessageApplyCredentials(_:_:_:_:_:) or CFHTTPMessageApplyCredentialDictionary(_:_:_:_:) to perform the authentication.

## See Also

### HTTP Authentication

- [CFHTTPAuthentication](cfnetwork/cfhttpauthentication.md)
- [CFHTTPAuthenticationAppliesToRequest(_:_:)](cfnetwork/cfhttpauthenticationappliestorequest(_:_:).md)
- [CFHTTPAuthenticationCopyDomains(_:)](cfnetwork/cfhttpauthenticationcopydomains(_:).md)
- [CFHTTPAuthenticationCopyMethod(_:)](cfnetwork/cfhttpauthenticationcopymethod(_:).md)
- [CFHTTPAuthenticationCopyRealm(_:)](cfnetwork/cfhttpauthenticationcopyrealm(_:).md)
- [CFHTTPAuthenticationGetTypeID()](cfnetwork/cfhttpauthenticationgettypeid().md)
- [CFHTTPAuthenticationIsValid(_:_:)](cfnetwork/cfhttpauthenticationisvalid(_:_:).md)
- [CFHTTPAuthenticationRequiresAccountDomain(_:)](cfnetwork/cfhttpauthenticationrequiresaccountdomain(_:).md)
- [CFHTTPAuthenticationRequiresOrderedRequests(_:)](cfnetwork/cfhttpauthenticationrequiresorderedrequests(_:).md)
- [CFHTTPAuthenticationRequiresUserNameAndPassword(_:)](cfnetwork/cfhttpauthenticationrequiresusernameandpassword(_:).md)
- [kCFHTTPAuthenticationAccountDomain](cfnetwork/kcfhttpauthenticationaccountdomain.md)
- [kCFHTTPAuthenticationPassword](cfnetwork/kcfhttpauthenticationpassword.md)
- [kCFHTTPAuthenticationSchemeBasic](cfnetwork/kcfhttpauthenticationschemebasic.md)
- [kCFHTTPAuthenticationSchemeDigest](cfnetwork/kcfhttpauthenticationschemedigest.md)
- [kCFHTTPAuthenticationSchemeKerberos](cfnetwork/kcfhttpauthenticationschemekerberos.md)
