Ping SDKs

Step 3. Test the app

In the following procedure, you run the sample app that you configured in the previous step.

  1. Add or connect a device to Android Studio.

    Learn more about devices in Android Studio in the Android Developer documentation:

  2. On the Run menu, click Run 'samples.app'.

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

    The app automatically starts the DaVinci flow:

    The DaVinci sample app first screen with fields and buttons.
    Figure 1. The DaVinci sample app first screen with fields and buttons.
  3. Optionally, to register a new identity in PingOne, tap the No Account? Register now! link.

    This link is an example of a FlowButton.

    The app displays the registration screen:

    The DaVinci sample app registration screen
    Figure 2. The DaVinci sample app registration screen.
    1. Enter the details of the new identity, and then click Save.

      The app creates the new identity in PingOne and returns to the sign on screen.

  4. Enter the username and password of a PingOne identity, and then click Sign On.

    The app sends the credentials to PingOne for validation, and on success displays the user’s info:

    The DaVinci sample app displaying user info
    Figure 3. The DaVinci sample app displaying user info
  5. Tap the menu () icon, and then tap generating_tokens Show Token.

    The app shows the access token obtained on behalf of the user.

    The DaVinci sample app displaying a user’s access token
    Figure 4. The DaVinci sample app displaying a user’s access token
  6. Tap the menu () icon, and then tap logout Logout.

    The app revokes the existing tokens and ends the session in PingOne.

Troubleshooting

This section contains help if you encounter an issue running the sample code.

What can cause validation errors in the request?

When starting the app you might see an error message as follows:

The request could not be completed. One or more validation errors were in the request.

davinci sample validation error en
Figure 5. Validation error when starting the app

The Logcat pane in Android Studio often contains additional information about the error:

{
  "id" : "2a72bf00-5f20-4b78-a7d0-ad8d95e9b11b",
  "code" : "INVALID_DATA",
  "message" : "The request could not be completed. One or more validation errors were in the request.",
  "details" : [
    {
      "code" : "INVALID_VALUE",
      "target" : "redirect_uri",
      "message" : "Redirect URI mismatch"
    }
  ]
}

In this case the cause is Redirect URI mismatch.

Ensure that your redirectUri value in com/pingidentity/samples/app/davinci/DaVinciViewModel.kt exactly matches one of the values you entered in the Redirect URIs field in your OAuth 2.0 application in PingOne:

.Match the redirect URIs in the sample app and PingOne configuration
Figure 6. Match the redirect URIs in the sample app and PingOne configuration