AuthenticationInterceptor
public final class AuthenticationInterceptor : Interceptor
Implementation of a request interceptor which handles authentication.
Currently there are four different authentication methods provided which are none, basicAuthentication, bearerToken and custom.
To be able to be highly flexible to also being able to switch between authentication methods, we provided the possibility to pass in an autoclosure
which is evaluated when this request is being intercepted.
-
The authentication methods currently supported.
See moreDeclaration
Swift
public enum AuthenticationMethod -
# Summary The initialiser for the
AuthenticationRequestInterceptorDeclaration
Swift
public init(authenticationMethod: @autoclosure @escaping (() -> AuthenticationMethod))Parameters
authenticationMethodEither pass in an enum case or an
autoclosurewhich then returns anAuthenticationMethod -
# Summary Intercepting the request by adding the authentication header according to the given authentication metod.
- When choosing
noneas authentication method nothing will be added to the request. - When choosing
basicAuthenticationa base 64 encoded string from the given username and password will be generated and added to the header fields of the request. - When choosing
bearerTokenthe given token will be added to the header fields of the request. When choosing
customthe given header field key and header field value will be added to the header fields of the request.
Declaration
Swift
public func intercept(_ request: URLRequest) -> URLRequestParameters
requestThe request to be intercepted.
Return Value
The intercepted request.
- When choosing
View on GitHub
Install in Dash
AuthenticationInterceptor Class Reference