ForgeRock SDKs

Android app

This page shows how to use the Android SDK with authentication journeys that provide social login and registration.

The first callback your app encounters is the SelectIdPCallback, which lets the user choose their IdP. You use the getProviders() method to display the available providers, and setValue when the user makes a choice:

List<SelectIdPCallback.IdPValue> providers = callback.getProviders();

The next callback is the IdPCallback. You call the signIn() method on the IdPCallback class:

callback.signIn(null, new FRListener<Void>() {
  public void onSuccess(Void result) {
    //proceed to next node;

  public void onException(Exception e) {
    //handle error

This method directs the user to authenticate with the IdP. When the user authenticates with that provider, the result is automatically added to the IdPCallback with the following methods:

idPCallback.setTokenType(String tokenType)
idPCallback.setToken(String token)

In order to override the automatic provider detection, and identify the returned provider manually, you must check the IdPClient provider value in the IdPCallback returned:

IdPHandler idPHandler = null;
  switch (callback.getProvider()) {
    case "facebook-android":
      idPHandler = new FacebookSignInHandler();
    case "google-android":
      idPHandler = new GoogleSignInHandler();
    case "apple-android":
      idPHandler = new AppleSignInHandler();

//  If the handler has been found and initialised, call the following to perform login
callback.signIn(idPHandler, new FRListener<Void>() {
  //  Social Login flow is completed

SDK configuration


For Google Sign-In, add the following dependency to the build.gradle file:

implementation ''


For Facebook Login:

  1. Add the Facebook dependency to the build.gradle file:

    implementation ''
  2. Add the following to the AndroidManifest.xml file:

    <meta-data android:name="com.facebook.sdk.ApplicationId"
    <activity android:name="com.facebook.FacebookActivity"
        android:label="@string/app_name" />
          <action android:name="android.intent.action.VIEW" />
          <category android:name="android.intent.category.DEFAULT" />
          <category android:name="android.intent.category.BROWSABLE" />
          <data android:scheme="@string/fb_login_protocol_scheme" />
  3. Add the following attributes to the string.xml file:

     <string name="facebook_app_id">Your Facebook AppId</string>
     <string name="fb_login_protocol_scheme">Your Facebook prototol scheme</string>

    To find the values of facebook_app_id and fb_login_protocol_scheme, go to Facebook Developer Console, select your app, then Facebook Login > Quickstart > Android, and follow the step to configure your application:

    Facebook scheme


For Sign in with Apple:

  1. Add the AppAuth dependency to the build.gradle file:

    implementation 'net.openid:appauth:0.11.1'
  2. Add the following to the AndroidManifest.xml file:

    <activity android:name="net.openid.appauth.RedirectUriReceiverActivity"
         <action android:name="android.intent.action.VIEW" />
         <category android:name="android.intent.category.DEFAULT" />
         <category android:name="android.intent.category.BROWSABLE" />
         <data android:scheme="@string/apple_scheme" />
  3. Add the following attribute to the string.xml file:

    <string name="apple_scheme">Your Redirect after form post URL Scheme</string>

    To find the value of apple_sheme, go to Services > Social Identity Provider Service > Secondary Configurations > Apple:

    Apple redirect after form post URL scheme

    From above example, the scheme would be org.forgerock.demo.

Copyright © 2010-2023 ForgeRock, all rights reserved.