For AI agents: visit https://developer.readyremit.com/llms.txt for an index of all pages formatted in Markdown and endpoints in OpenAPI.
+-------------+ +----------+ +----------+
| Customer |----(1)--->| Customer |----(2)--->| PayMitto |
| Application |<---(4)----| API |<---(3)----| API |
+-------------+ +----------+ +----------+
|
| +----------+
-----------(5)--->| PayMitto |
| SDK |
+----------+
- Customer application makes a network request to the Customer API to initiate the creation
of an access token for the PayMitto SDK
- Customer API makes a network request to the PayMitto API to create an access token for
the PayMitto SDK
- PayMitto API returns the access token details or an error
- Customer API returns the access token details or an error
- Customer application returns the access token details or throws an error
() async throws -> AccessTokenDetails
| Type | Description |
|---|
| AccessTokenDetails | A credential representing the authorization granted by the resource owner (user) to the PayMitto SDK |
struct CreateAccessTokenDetailsResponse: AccessTokenDetails {
var accessToken: String
var expiresIn: Int
var scope: String
var tokenType: String
}
private func fetchAccessTokenDetails() async throws -> AccessTokenDetails {
guard let url = URL(string: "https://example.com/v1/oauth/token") else {
throw URLError(.badURL)
}
var urlRequest = URLRequest(url: url)
urlRequest.httpMethod = "POST"
let (data, urlResponse) = try await URLSession.shared.data(for: urlRequest)
guard let httpURLResponse = urlResponse as? HTTPURLResponse else {
throw URLError(.badServerResponse)
}
switch httpURLResponse.statusCode {
case 200...299:
return try JSONDecoder().decode(CreateAccessTokenDetailsResponse.self, from: data)
default:
throw CustomError.unsuccessfulResponse
}
}