ApiAuthentication
@available(macOS 10.15, iOS 13.0, *)
public class ApiAuthentication : ApiAuthenticationInterface
This is the REST API authentication method that I usually use You can implement your own and set it as default REST API authentication on the SwiftlyRest class
Check this repository for more information https://github.com/PedroCavaleiro/api-app-authentication
-
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
public var headers: [String : String] -
Initializes the API authentication with the required parameters.
Declaration
Swift
public init( deviceUuid: String, appId: String, appKey: String, userAgent: String = "SwiftlyRest" )Parameters
deviceUuidThe unique identifier for the device, used to generate the browser fingerprint.
appIdThe application identifier, used to authenticate the app.
appKeyThe application key, used for additional security in the authentication process.
userAgentThe user agent string of the client, defaulting to “SwiftlyRest”.
-
Generates the headers to authenticate with the API This authenticates both the client and the user
Declaration
Swift
public func generateHeaders<T: Codable>( forMethod method: HTTPMethod, forBody body: T?, withJwt jwt: String? ) -> [String: String]Parameters
methodThe
HTTPMethodof the requestbodyThe body of the request, nil
ifnone, must becodablejwtThe JWT token for the user authentication,
nilfor no authentication