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 2. Preparing the authorization server
The tutorial supports both PingOne Advanced Identity Cloud and PingAM.
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:
-
In a web browser, navigate to https://github.com/ForgeRock/ping-android-sdk.
-
Download the source code using one of the following methods:
- Download a ZIP file
-
-
Click Code, and then click Download ZIP.
-
Extract the contents of the downloaded ZIP file to a suitable location.
-
- Use a Git-compatible tool to clone the repo locally
-
-
Click Code, and then copy the HTTPS URL.
-
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:
-
In the cloned repository, create an
assetsfolder insidesamples/pingsampleapp/src/main/. -
Save the following JSON template in the new folder as
rar-payment-initiation.json:Exampleping-android-sdk/samples/pingsampleapp/src/main/assets/rar-payment-initiation.jsonfile{ "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) } } -
Ensure the following properties match your environment:
Property Description 1
clientIdEnter the client ID you created for the app in the authorization server.
Leave as
rarClientif you named the client as suggested in Step 2. Prepare the authorization server.2
discoveryEndpointReplace
<your-tenant>with your PingOne Advanced Identity Cloud tenant or PingAM server URL.The example path uses the
alpharealm; adjust the realm path if your client is in a different realm.3
redirectUriEnter the redirect URI to return to the app after authorization.
For example,
org.pingidentity.demo://callback.4
parWe recommend using PAR alongside RAR flows.
Set this property to
trueto 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.
-
In Android Studio, open the cloned repository’s
samples/pingsampleappfolder.Android Studio syncs the Gradle project and builds the sample, including the
rar-payment-initiation.jsonpreset file from the previous step, so the sample is ready to use when it launches. -
Add or connect a device to Android Studio. Learn more about devices in Android Studio in the Android Developer documentation:
-
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.
-
On the main screen of the sample app, tap OIDC RAR Login.
The screen shows the selected config, whether PAR is on, and whether config-level authorization details are set.
-
Tap the login button.
The app opens the browser, you sign in, and the authorization server redirects to the RCS consent page.
-
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 The sample surfaces the error message. |
Troubleshooting
Use the following troubleshooting advice if the sample does not work as expected.
What you see |
What it means |
Granted |
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 |
RAR processing never ran. Check the Rich Authorization Requests with Remote Consent Service provider toggle, and the tenant version on PingOne Advanced Identity Cloud. |
|
The requested type is not in the client’s Authorization Detail Type(s) list. |
|
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. |