Orchestration SDKs

Integrating RAR into an iOS app

PingOne Advanced Identity Cloud PingAM iOS

The Orchestration SDK for iOS provides typed support for Rich Authorization Requests (RAR, RFC 9396) by using the PingOidc 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:

Example AuthorizationDetail object describing a specific payment
let payment = AuthorizationDetail(
    type: "payment_initiation",
    locations: ["https://example.com/payments"],
    actions: ["initiate"],
    additionalFields: [
        "instructedAmount": .object(["currency": .string("EUR"), "amount": .string("123.50")]),
        "creditorName": .string("Merchant A")
    ]
)

The type field is required; locations, actions, datatypes, and privileges are the common optional fields defined by RFC 9396, and are modeled as initializer parameters. Pass the type-specific fields, such as instructedAmount, in additionalFields.

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:

let result = try await web.authorize { options in
    options.authorizationDetails = [payment]
}
Configuring the PingOidc module

Add an authorizationDetails property when configuring the PingOidc module:

rarLoginClient = OidcWebClient.createOidcWebClient { config in
    config.module(PingOidc.OidcModule.config) { oidcValue in
        oidcValue.discoveryEndpoint = "https://openam-forgerock-sdks.forgeblocks.com/am/oauth2/realms/alpha/.well-known/openid-configuration"
        oidcValue.clientId = "sdkPublicClient"
        oidcValue.redirectUri = "org.pingidentity.demo://callback"
        oidcValue.par = true
        oidcValue.authorizationDetails = [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:

Example of keeping RAR tokens in separate storage (PingOne Advanced Identity Cloud)
// The original sign-in (Token A)
let journeyUser = await journey.journeyUser()

// The RAR transaction login (Token B), in its own storage.
// Configure the client once, at app startup:
let rarLoginClient = OidcWebClient.createOidcWebClient { config in
    config.module(PingOidc.OidcModule.config) { oidcValue in
        oidcValue.clientId = "sdkPublicClient"
        oidcValue.discoveryEndpoint = "https://openam-forgerock-sdks.forgeblocks.com/am/oauth2/realms/alpha/.well-known/openid-configuration"
        oidcValue.redirectUri = "org.pingidentity.demo://callback"
        oidcValue.par = true

        // A distinct keychain account keeps the RAR token out of the
        // storage used by the original sign-in
        oidcValue.storage = KeychainStorage<Token>(
            account: "RAR_ACCESS_TOKEN_STORAGE",
            encryptor: SecuredKeyEncryptor() ?? NoEncryptor()
        )
    }
}

// For each RAR transaction, build the authorizationDetail:
let payment = AuthorizationDetail(
    type: "payment_initiation",
    locations: ["https://example.com/payments"],
    actions: ["initiate"],
    additionalFields: [
        "instructedAmount": .object(["currency": .string("EUR"), "amount": .string("123.50")]),
        "creditorName": .string("Merchant A")
    ]
)

// Then authorize, passing the detail per call:
let rarResult = try await rarLoginClient.authorize { options in
    options.authorizationDetails = [payment]
}

Reading the granted details

The authorization server echoes the details it actually granted in the token response, and the PingOidc module decodes them onto the token.

The granted set can differ from the requested set, so check it rather than assuming:

Example reading the granted authorization_details from the token
if case .success(let token) = await user.token() {
    token.authorizationDetails?.forEach { detail in
        print("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 agent’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