Initializes an authentication challenge from parameters you provide.
- iOS 2.0+
- macOS 10.2+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
The protection space for the authentication challenge. This provides additional information about the authentication request, such as the host, port, authentication realm, and so on.
The proposed credential, or
The total number of previous failures for this request, including failures for other protection spaces.
An instance of
URLResponsecontaining the server response that caused you to generate an authentication challenge, or
nilif no response object is applicable to the challenge.
Errorinstance describing the authentication failure, or
nilif it is not applicable to the challenge.
The object that initiated the authentication challenge (typically, the object that called this method).
A new authentication challenge object, with the given properties.
Most apps don’t create
URLAuthentication instances themselves. Instead, they handle received challenges in the
url method of
However, you might need to create authentication challenge objects when adding support for custom networking protocols, as part of your custom