Ping SDKs

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.

  1. In Android Studio, open the sdk-sample-apps/android/kotlin-ui-prototype folder you cloned in the previous step.

  2. In the Project pane, switch to the Android view.

  3. 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.

  4. 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:

    1. Log in to your PingFederate administration console.

    2. Navigate to System  Server  Protocol Settings.

    3. Make a note of the Base URL value.

      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"
        }
    }
  5. In the init object, check that PingFederate 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.