Orchestration SDKs

Running a RAR flow in iOS

PingOne Advanced Identity Cloud PingAM iOS

In this tutorial you run a complete RAR payment transaction in the OidcExample sample app from the Orchestration SDK sample apps repository.

The app requests authorization for a specific payment, the user approves the payment details on the Remote Consent Service page, and the app displays the granted details from the token response.

Before you begin

Ensure that you have completed the following prerequisite tasks before attempting to run the sample app:

PingOne Advanced Identity Cloud only: your tenant must run PingOne Advanced Identity Cloud version 23604.0 or later, or the authorization server issues an empty authorization_details grant.

If you test on the iOS simulator, install the mkcert root certificate into each simulator you test on:

xcrun simctl keychain booted add-root-cert "$(mkcert -CAROOT)/rootCA.pem"

The simulator does not inherit your Mac’s certificate trust settings. Without the certificate, the consent page fails with a "This Connection Is Not Private" error in the simulator, even though the same URL loads in your Mac’s browser.

Step 1. Downloading the sample app

In this step you download the Orchestration SDK sample apps repository containing the OidcExample sample app.

To download or clone a copy of the SDK Sample Apps repo, complete these steps:

  1. In a web browser, navigate to https://github.com/ForgeRock/sdk-sample-apps.

  2. Download the source code using one of the following methods:

    Download a ZIP file
    1. Click Code, and then click Download ZIP.

      download samples zip
      Figure 1. Downloading a zip file of the sample apps repo.
    2. Extract the contents of the downloaded ZIP file to a suitable location.

    Use a Git-compatible tool to clone the repo locally
    1. Click Code, and then copy the HTTPS URL.

      download samples git clone
      Figure 2. Downloading the sample apps repo using Git clone.
    2. Use the URL to clone the repository to a suitable location.

      For example, from the command-line you could run:

      git clone https://github.com/ForgeRock/sdk-sample-apps.git

After completing these steps, you will have a local folder named sdk-sample-apps. Inside, you’ll find separate folders for the Android, iOS, JavaScript, and React Native sample app projects.

The sample app is in iOS/swiftui-oidc-module in the cloned repository.

Step 2. Configuring the sample app

In this step you set the connection properties for your RAR-enabled client in the sample’s source code, and register the redirect URI scheme in Xcode.

The sample authenticates as two OAuth 2.0 clients: a standard client for the plain login, and a dedicated RAR client for the RAR login. Configure both.

  1. Open iOS/swiftui-oidc-module/OidcExample.xcodeproj in Xcode. There is no workspace file for this sample.

  2. In OidcExample/ViewModels/OidcLoginViewModel.swift, replace the editor placeholders in makeOidcWebClient(overrides:) with your authentication OAuth 2.0 client values:

    oidcValue.clientId = "sdkPublicClient" (1)
    oidcValue.scopes = Set(["openid", "profile", "email", "address"]) (2)
    oidcValue.redirectUri = "com.example.demo://oauth2redirect" (3)
    oidcValue.discoveryEndpoint = "https://openam-forgerock-sdks.forgeblocks.com/am/oauth2/realms/alpha/.well-known/openid-configuration" (4)
    1 The client ID of the standard client you registered in Step 2. Preparing the authorization server.
    2 The scopes registered on your clients, matching the scopes you set in Step 2. Preparing the authorization server. The scopes value must be a Set, not an array.
    3 The redirect URI registered on your standard client. For example, com.example.demo://oauth2redirect.
    4 The discovery endpoint of your PingOne Advanced Identity Cloud tenant or PingAM server. The example path uses the alpha realm; adjust the realm path if your client is in a different realm.
  3. In OidcExample/Configuration/RarClientStore.swift, replace the RAR Client ID placeholder with the client ID of your RAR-enabled client.

    For example, rarClient, the client ID suggested in Step 2. Preparing the authorization server.

  4. Register the redirect URI scheme in Xcode:

    1. Select the project in the Project Navigator.

    2. Open the Info tab, and expand URL Types.

    3. Add a URL scheme matching the scheme of your redirect URI.

      For example, if your redirect URI is com.example.demo://oauth2redirect, use the following values:

      • URL Schemes: The scheme portion of your deep link, for example com.example.demo.

      • Identifier: The part of the redirect URI after the :// symbol, for example oauth2redirect.

Step 3. Building and running the sample app

In this step you build the sample and run it on a simulator or physical device.

  1. In Xcode, build and run the OidcExample scheme on a simulator or a physical device.

    The app displays the main menu:

    swiftui oidc sample menu
    Figure 3. The OidcExample main menu
  2. Tap Launch OIDC Login, tap Start OIDC Login, and then authenticate as a demo user.

    Tap Continue if the sample asks whether you want to open the browser to authenticate on your tenant.

  3. After successfully authenticating, tap Back to return to the menu screen.

  4. Tap Launch RAR Login.

    The app displays the RAR Login page:

    swiftui oidc rar menu
    Figure 4. The RAR Login page
  5. Select the payment_initiation preset, or swipe across to the Custom option and enter your own authorization details JSON.

    The preset requests a payment of 123.50 EUR to Merchant A:

    Example authorization_details preset requesting a payment of 123.50 EUR to Merchant A
    [
      {
        "type": "payment_initiation",
        "locations": ["https://example.com/payments"],
        "instructedAmount": {"currency": "EUR", "amount": "123.50"},
        "creditorName": "Merchant A",
        "creditorAccount": {"iban": "GB29MRCH60161331926819"},
        "remittanceInformationUnstructured": "Ref Number Merchant"
      }
    ]
  6. Scroll to the bottom of the page and tap Login with authorization_details.

    The app opens the browser, connects to your tenant, which redirects you to the local RCS server for your consent.

    swiftui oidc rar consent
    Figure 5. The Remote Consent Service consent page
  7. Review the payment details on the consent page, and then tap Approve:

    The RCS returns its signed consent response, and the authorization server redirects back to the app with an authorization code.

  8. Tap View RAR Access Token to check that the token response contains the authorization details you approved on the consent page.

Troubleshooting

Use the following troubleshooting advice if the sample does not work as expected.

Troubleshooting the result
What you see What it means

Granted authorization_details is an empty array []

RAR processing ran, but the consent response carried no details. Either the RCS has no enricher for the requested type and dropped it, or the consent response did not echo the claim.

No authorization_details in the token response at all

RAR processing never ran. Check the Rich Authorization Requests with Remote Consent Service provider toggle, and the tenant version on PingOne Advanced Identity Cloud.

invalid_authorization_details at the authorize step

The requested type is not in the client’s Authorization Detail Type(s) list.

invalid_request at the authorize step

The client has implied consent enabled, which is incompatible with RAR. Turn implied consent off.

Consent page fails with a JWT signature error

The Remote Consent Agent’s signing algorithm does not match the RCS. With the demonstration RCS, set the agent to HS256.

"Unexpected number of Base64URL parts, must be three"

Consent request encryption is enabled on the agent. Turn it off; the demonstration RCS reads signed, not encrypted, JWTs.