Integrating RAR into an Android app
PingOne Advanced Identity Cloud PingAM Android
The Orchestration SDK for Android provides typed support for Rich Authorization Requests (RAR, RFC 9396) by using the OIDC module.
You describe what the user is approving with AuthorizationDetail objects, the SDK sends them as the authorization_details parameter, and the details the server granted are echoed back with the token.
This page shows you how to add RAR to an existing app that signs on with PingOne Advanced Identity Cloud or PingAM.
Requesting authorization details
The first step in implementing RAR is to describe the details of what the user should authorize, so the server can present them as a rich consent. To do this, create AuthorizationDetail objects:
AuthorizationDetail object describing a specific paymentval payment = AuthorizationDetail(
type = "payment_initiation",
actions = listOf("initiate"),
locations = listOf("https://example.com/payments"),
additionalFields = mapOf(
"instructedAmount" to mapOf("currency" to "EUR", "amount" to "123.50"),
"creditorName" to "Merchant A",
),
)
The type field is required; locations, actions, datatypes, and privileges are the common optional fields defined by RFC 9396.
After creating the authorization detail, you can provide it to the Orchestration SDK during either of the following actions:
- Starting the OIDC flow
-
Per-call details are the natural fit for transactions, because each payment is a new consent:
web.authorize { authorizationDetails(payment) } - Configuring the OIDC module
-
Add an
authorizationDetailsproperty when configuring the OIDC module:val rarLoginClient = OidcWebClient { module(com.pingidentity.oidc.module.Oidc) { discoveryEndpoint = "https://openam-forgerock-sdks.forgeblocks.com/am/oauth2/realms/alpha/.well-known/openid-configuration" clientId = "sdkPublicClient" redirectUri = "org.pingidentity.demo://callback" par = true authorizationDetails = listOf(payment) } }
Running RAR alongside an existing login
A RAR login usually happens after the user has already signed in, so the app holds two tokens: the original login token, and the token issued for the RAR transaction.
To keep both tokens and prevent them either overwriting one another, or being revoked by the Orchestration SDK, give the RAR login its own storage configuration:
// The original sign-in (Token A)
val journeyUser = journey.user()
// The RAR transaction login (Token B), in its own storage.
// Configure the client once, at app startup:
val rarLoginClient = OidcWebClient {
module(com.pingidentity.oidc.module.Oidc) {
clientId = "sdkPublicClient"
discoveryEndpoint = "https://openam-forgerock-sdks.forgeblocks.com/am/oauth2/realms/alpha/.well-known/openid-configuration"
redirectUri = "org.pingidentity.demo://callback"
par = true
storage {
// A distinct file name keeps the RAR token out of the
// storage used by the original sign-in
fileName = "com.pingidentity.sdk.v1.rar.tokens"
keyAlias = "com.pingidentity.sdk.v1.rar.tokens"
}
}
}
// For each RAR transaction, build the authorizationDetail:
val payment = AuthorizationDetail(
type = "payment_initiation",
actions = listOf("initiate"),
locations = listOf("https://example.com/payments"),
additionalFields = mapOf(
"instructedAmount" to mapOf("currency" to "EUR", "amount" to "123.50"),
"creditorName" to "Merchant A",
),
)
// Then authorize, passing the detail per call:
val rarResult = rarLoginClient.authorize {
authorizationDetails(payment)
}
Reading the granted details
The authorization server echoes the details it actually granted in the token response, and the OIDC module decodes them onto the token.
The granted set can differ from the requested set, so check it rather than assuming:
authorization_details from the tokenval token = web.user().token()
token.authorizationDetails?.let { granted ->
granted.forEach { detail ->
println("Granted type: ${"$"}{detail.type}")
}
}
Understanding the limitations
RAR is only supported by the browser-based OIDC sign-on flow, as it is the only one that displays a rich consent screen.
Native journeys cannot carry RAR
The journey module’s re-authorize request is a headless call that exchanges tokens in the background and never displays a consent page. If you send authorization_details on that path, the server rejects the request.
In practice this means a user who signs in with a native journey has consented to the scopes on that journey, but you cannot use that sign-in to get consent for a transaction such as a payment.
To get transaction consent for those users, run a separate browser-based OIDC authorization for the transaction, as shown in Running RAR alongside an existing login.
Device authorization flows cannot initiate RAR
Device authorization is designed for input-constrained devices such as smart TVs that cannot display a rich consent page, so the server ignores authorization_details in the device authorization request. The SDK’s device client does not send the parameter at all.
In practice this means a TV or streaming device cannot use RAR to ask the user to approve a specific transaction. If your app covers such devices, treat the transaction approval as a separate step the user completes on the consent-capable device, or scope the device’s access with ordinary scopes instead.
Next steps
-
See the complete flow working: Running a RAR flow in Android