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
deviceUuid
The unique identifier for the device, used to generate the browser fingerprint.
appId
The application identifier, used to authenticate the app.
appKey
The application key, used for additional security in the authentication process.
userAgent
The 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
method
The
HTTPMethod
of the requestbody
The body of the request, nil
if
none, must becodable
jwt
The JWT token for the user authentication,
nil
for no authentication