authenticateIntoTheSdk
A callback to retrieve credentials to interface with the ReadyRemit API onbehalf of the sender
Overview
+-------------+ +----------+ +------------+
| Customer |----(2)--->| Customer |----(3)--->| ReadyRemit |
| Application |<---(5)----| API |<---(4)----| API |
+-------------+ +----------+ +------------+
|
| +------------+
<----------(1)----| ReadyRemit |
-----------(6)--->| SDK |
+------------+- SDK calls back the authenticateIntoTheSdk to request a new authentication token.
- Customer application makes a network request to the Customer API to initiate the creation of an access token for the ReadyRemit SDK.
- Customer API makes a network request to the ReadyRemit API to create an access token for the ReadyRemit SDK.
- ReadyRemit 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 and makes
authenticateIntoTheSdkcallback return andAuthenticationResultobject (Success or Error).
Expected objects to be sent by the app in the callback response to the sdk
| Type | Description |
|---|---|
| AccessTokenDetails | A credential representing the authorization granted by the resource owner (user) to the ReadyRemit SDK. |
| ReadyRemitError | A generic representation of an error for the ReadyRemit SDK. |
Sample Implementation
private val authenticateIntoTheSdk = suspend {
withContext(Dispatchers.IO) {
val authRequest = AuthRequest(
clientId = "client_id",
clientSecret = "client_secret",
audience = "audience",
grantType = "grant_type",
senderId = "sender_id"
)
val response = oAuthApi.requestAuth(authURL, authRequest)
val accessTokenResponse = response.body()
if (response.isSuccessful && accessTokenResponse != null) {
tokenValue = accessTokenResponse.accessToken
AuthenticationResult.Success(
AccessTokenDetails(
accessToken = accessTokenResponse.accessToken,
expiresIn = accessTokenResponse.expiresInSeconds,
scope = accessTokenResponse.scope,
tokenType = accessTokenResponse.tokenType
)
)
} else {
AuthenticationResult.Error(
ReadyRemitError(
code = response.code().toString(),
message = response.message()
)
)
}
}
}
Updated 8 days ago
