Step 2. Configure the sample app
In this step, you configure the "kotlin-ui-prototype" sample to connect to the OAuth 2.0 application you created in PingFederate, using the centralized login method.
-
In Android Studio, open the
sdk-sample-apps/android/kotlin-ui-prototype
folder you cloned in the previous step. -
In the Project pane, switch to the Android view.
-
In the Android view, navigate to app > kotlin+java > com.example.app > env, and open
EnvViewModel.kt
.This file has the server environments the sample app uses. Each specifies the properties using the
FROptionsBuilder.build
method. -
Update the
PingFederate
example configuration with your environment’s details:// Example values for a PingFederate instance val PingFederate = FROptionsBuilder.build { server { url = "<PingFederate Base URL>" } oauth { oauthClientId = "<PingFederate Client ID>" oauthRedirectUri = "org.forgerock.demo://oauth2redirect" oauthSignOutRedirectUri = "org.forgerock.demo://oauth2redirect" oauthScope = "openid profile email address" } }
Replace the following string with the value you obtained when you registered an OAuth 2.0 application in PingFederate.
- <PingFederate Client ID>
-
The client ID from your OAuth 2.0 application in PingFederate.
For example,
sdkPublicClient
- <PingFederate Base URL>
-
The
Base URL
of your PingFederate server.How do I find my PingFederate Base URL?
To verify the base URL of your PingFederate server:
-
Log in to your PingFederate administration console.
-
Navigate to
. -
Make a note of the Base URL value.
For example,
https://pingfed.example.com
Do not use the admin console URL.
The sample code adds
/.well-known/openid-configuration
after the base URL value to form the.well-known
endpoint of your server. The SDK reads the OAuth 2.0 paths it requires from this endpoint. -
The result resembles the following:
val PingFederate = FROptionsBuilder.build { server { url = "https://pingfed.example.com" } oauth { oauthClientId = "sdkPublicClient" oauthRedirectUri = "org.forgerock.demo://oauth2redirect" oauthSignOutRedirectUri = "org.forgerock.demo://oauth2redirect" oauthScope = "openid profile email address" } }
-
In the
init
object, check thatPingFederate
is in the list of server configurations available to the sample app:For example:
init { servers.add(PingAM) servers.add(PingAdvancedIdentityCloud) servers.add(PingOne) servers.add(PingFederate) }
With the sample configured, you can proceed to Step 3. Run the sample app and perform centralized login.