docs/docsets/Alamofire.docset/Contents/Resources/Documents/Classes/AuthenticationInterceptor.html
public final class AuthenticationInterceptor<AuthenticatorType> : RequestInterceptor, Sendable where AuthenticatorType : Authenticator
The AuthenticationInterceptor class manages the queuing and threading complexity of authenticating requests. It relies on an Authenticator type to handle the actual URLRequest authentication and Credential refresh.
`
Credential
`
Type of credential used to authenticate requests.
Swift
public typealias Credential = AuthenticatorType.Credential
`
RefreshWindow
`
Type that defines a time window used to identify excessive refresh calls. When enabled, prior to executing a refresh, the AuthenticationInterceptor compares the timestamp history of previous refresh calls against the RefreshWindow. If more refreshes have occurred within the refresh window than allowed, the refresh is cancelled and an AuthorizationError.excessiveRefresh error is thrown.
Swift
public struct RefreshWindow
`
credential
`
The Credential used to authenticate requests.
Swift
public var credential: Credential? { get set }
`
init(authenticator:credential:refreshWindow:)
`
Creates an AuthenticationInterceptor instance from the specified parameters.
A nil RefreshWindow will result in the AuthenticationInterceptor not checking for excessive refresh calls. It is recommended to always use a RefreshWindow to avoid endless refresh cycles.
Swift
public init(authenticator: AuthenticatorType,
credential: Credential? = nil,
refreshWindow: RefreshWindow? = RefreshWindow())
| authenticator |
The Authenticator type.
|
| credential |
The Credential if it exists. nil by default.
|
| refreshWindow |
The RefreshWindow used to identify excessive refresh calls. RefreshWindow() by default.
|
`
adapt(_:for:completion:)
`
Swift
public func adapt(_ urlRequest: URLRequest, for session: Session, completion: @escaping @Sendable (Result<URLRequest, any Error>) -> Void)
`
retry(_:for:dueTo:completion:)
`
Swift
public func retry(_ request: Request, for session: Session, dueTo error: any Error, completion: @escaping @Sendable (RetryResult) -> Void)