Class

NSURLAuthenticationChallenge

A challenge from a server requiring authentication from the client.

Overview

Your app receives authentication challenges in various NSURLSession, NSURLConnection, and NSURLDownload delegate methods, such as URLSession:task:didReceiveChallenge:completionHandler:. These objects provide the information you’ll need when deciding how to handle a server’s request for authentication.

At the core of that authentication challenge is a protection space that defines the type of authentication being requested, the host and port number, the networking protocol, and (where applicable) the authentication realm (a group of related URLs on the same server that share a single set of credentials).

Topics

Creating an Authentication Challenge Instance

initWithAuthenticationChallenge:sender:

Creates an authentication challenge from an existing challenge instance.

initWithProtectionSpace:proposedCredential:previousFailureCount:failureResponse:error:sender:

Initializes an authentication challenge from parameters you provide.

Inspecting the Authentication Challenge

protectionSpace

The receiver’s protection space.

Getting Properties of Previous Authentication Attempts

failureResponse

The URL response object representing the last authentication failure.

previousFailureCount

The receiver’s count of failed authentication attempts.

proposedCredential

The proposed credential for this challenge.

Getting Authentication Errors

error

The error object representing the last authentication failure.

Legacy

sender

The sender of the challenge.

Relationships

Inherits From

Conforms To

See Also

Authentication and Credentials

Handling an Authentication Challenge

Respond appropriately when a server demands authentication for a URL request.

NSURLCredential

An authentication credential consisting of information specific to the type of credential and the type of persistent storage to use, if any.

NSURLCredentialStorage

The manager of a shared credentials cache.

NSURLProtectionSpace

A server or an area on a server, commonly referred to as a realm, that requires authentication.