Orchestration SDKs

Running a RAR flow in Android

PingOne Advanced Identity Cloud PingAM Android

In this tutorial you run a complete RAR payment transaction in the pingsampleapp sample app from the Orchestration SDK for Android 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:

Step 1. Downloading the sample app

In this step you download the Orchestration SDK for Android repository containing the pingsampleapp sample app.

To download or clone a copy of the Android Orchestration SDK repository, complete these steps:

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

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

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

    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.

    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/ping-android-sdk.git

After completing these steps, you will have a local folder named ping-android-sdk. The RAR tutorial uses the pingsampleapp sample in the samples folder.

Step 2. Configuring the sample app

In this step you create the JSON preset file that configures the sample for your RAR-enabled client.

The sample loads its connection settings from a JSON preset file bundled into the app at build time.

Create the preset file for your RAR-enabled client:

  1. In the cloned repository, create an assets folder inside samples/pingsampleapp/src/main/.

  2. Save the following JSON template in the new folder as rar-payment-initiation.json:

    Example ping-android-sdk/samples/pingsampleapp/src/main/assets/rar-payment-initiation.json file
    {
      "oidc": {
        "clientId": "rarClient", (1)
        "discoveryEndpoint": "https://<your-tenant>/am/oauth2/realms/root/realms/alpha/.well-known/openid-configuration", (2)
        "redirectUri": "org.pingidentity.demo://callback", (3)
        "scopes": ["openid"],
        "par": true (4)
      }
    }
  3. Ensure the following properties match your environment:

    Property Description

    1 clientId

    Enter the client ID you created for the app in the authorization server.

    Leave as rarClient if you named the client as suggested in Step 2. Prepare the authorization server.

    2 discoveryEndpoint

    Replace <your-tenant> with your PingOne Advanced Identity Cloud tenant or PingAM server URL.

    The example path uses the alpha realm; adjust the realm path if your client is in a different realm.

    3 redirectUri

    Enter the redirect URI to return to the app after authorization.

    For example, org.pingidentity.demo://callback.

    4 par

    We recommend using PAR alongside RAR flows.

    Set this property to true to enable PAR.

Step 3. Building and running the sample app

In this step you open the sample app in Android Studio, build it, and run it on a device or simulator.

  1. In Android Studio, open the cloned repository’s samples/pingsampleapp folder.

    Android Studio syncs the Gradle project and builds the sample, including the rar-payment-initiation.json preset file from the previous step, so the sample is ready to use when it launches.

  2. Add or connect a device to Android Studio. Learn more about devices in Android Studio in the Android Developer documentation:

  3. Select Run > Run 'pingsampleapp'.

    Android Studio starts the sample application on the simulated or connected device.

Step 4. Requesting the payment authorization

In this step you run the complete RAR payment transaction in the sample app, from login to consent approval.

  1. On the main screen of the sample app, tap verified_user OIDC RAR Login.

    The screen shows the selected config, whether PAR is on, and whether config-level authorization details are set.

  2. Tap the login button.

    The app opens the browser, you sign in, and the authorization server redirects to the RCS consent page.

  3. Review the payment details on the consent page, and approve them.

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

    The app exchanges the code and displays the token.

Step 5. Verifying the granted details

In this step you check that the token response contains the authorization details you approved on the consent page.

On the token screen, the app renders the granted authorization_details from the token response, one entry per requested object.

Check that the granted details match the payment you approved: type payment_initiation, the instructed amount, and the creditor.

Deny path

If you decline the payment on the RCS consent page, the authorization server rejects the flow, and the redirect back to the app carries an access_denied error instead of an authorization code.

The sample surfaces the error message.

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.