Class

URLAuthenticationChallenge

A challenge from a server requiring authentication from the client.

Overview

Your app receives authentication challenges in various URLSession, NSURLConnection, and NSURLDownload delegate methods, such as urlSession(_:task:didReceive: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

Inspecting the Authentication Challenge

var protectionSpace: URLProtectionSpace

The receiver’s protection space.

Getting Properties of Previous Authentication Attempts

var failureResponse: URLResponse?

The URL response object representing the last authentication failure.

var previousFailureCount: Int

The receiver’s count of failed authentication attempts.

var proposedCredential: URLCredential?

The proposed credential for this challenge.

Getting Authentication Errors

var error: Error?

The error object representing the last authentication failure.

Legacy

Relationships

Inherits From

See Also

Authentication and Credentials

Handling an Authentication Challenge

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

class URLCredential

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

class URLCredentialStorage

The manager of a shared credentials cache.

class URLProtectionSpace

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