ApiAuthenticationInterface
public protocol ApiAuthenticationInterface
A protocol that defines the requirements for API authentication mechanisms.
Conforming types must provide a set of headers for authentication and a method to generate authentication headers for API requests, supporting both client and user authentication via JWT tokens.
-
The default headers used for API authentication. These headers are typically included in every request to identify the client or provide static authentication information.
Declaration
Swift
var headers: [String : String] { get } -
Generates the headers required to authenticate with the API for a specific request. This method should return a dictionary of headers that authenticate both the client and the user (if a JWT is provided).
Declaration
Swift
func generateHeaders<T: Codable>( forMethod method: HTTPMethod, forBody body: T?, withJwt jwt: String? ) -> [String: String]Parameters
methodThe HTTP method of the request (e.g., GET, POST).
bodyThe body of the request, or
nilif none. The body must conform toCodable.jwtThe JWT token for user authentication, or
nilif no user authentication is required.Return Value
A dictionary of headers to be included in the API request.