Android PingOne Mobile SDK API


Overview

The PingOne Mobile SDK provides the ability to integrate PingOne MFA functionality into your mobile applications.

The PingOne Mobile SDK API for Android is included in the SDK package. The functions, parameters and error codes are listed below.

The PingOne Mobile SDK package is available for download at https://github.com/pingidentity/pingone-customers-mobile-sdk. Further details for setup and integrating PingOne Mobile SDK into your mobile apps are available in the README file in the Android folder of the downloadable package.

See Edit an application in the admin guide for the server-side configuration steps.

PingOne Mobile SDK API - Android

PingOne main public class

/**
* Created by Ping Identity
* Copyright © 2019 Ping Identity. All rights reserved.
* Version 1.1.0
*
* Main public class that contains APIs
*/
public class PingOne {

    /**
    * Callback interface that will notify developers about task completion
    * PingOneSDKError object will be null if process completed successfully
    */
    public interface PingOneSDKCallback {
	    void onComplete(@Nullable PingOneSDKError error);
    }
	
    /**
    * Callback interface that will notify developers about processRemoteNotification task completion
	* NotificationObject will be returned if process completed successfully
	* PingOneSDKError object will be null if process completed successfully
	*/
    public interface PingOneNotificationCallback {
	   void onComplete(@Nullable NotificationObject notificationObject, @Nullable PingOneSDKError error);
	}
	
    /**
     * Callback interface that will notify developers about processIdToken task completion
     * PairingObject will be returned if process completed successfully
     * PingOneSDKError object will be null if process completed successfully.
     * onComplete(null, null) will be triggered on OIDC login with already paired device
     */
     public interface PingOnePairingCallback {
         void onComplete(@Nullable PairingObject pairingObject, @Nullable PingOneSDKError error);
     }
	
	/**
	* Pairs the device with the PingOne server using the pairing key
	* @param context   application context
	* @param pairingKey    pairing key as a String
	* @param callback  notifies a completion
	**/
	public static void pair(Context context, String pairingKey, PingOneSDKCallback callback)
	
	/**
	* Set device’s remote notification token.
	* @param context an application context
	* @param fcmRegistrationIdToken the registration token retrieved from FCM
	* @param callback notifies a completion
	*/
	public static void setDeviceToken(Context context, String fcmRegistrationIdToken, PingOneSDKCallback callback)
	
	/**
	* Process the remote notification received from PingOne
	* @param remoteMessage a remote message retrieved from FCM
	* @param callback PingOneNotificationCallback notifies about task completion. Will return
	* NotificationObject if process completed successfully, or PingOneSDKError if unsuccessful
	*/
	public static void processRemoteNotification(RemoteMessage remoteMessage, PingOneNotificationCallback callback)
	
    /**
    * Returns a payload string for any communication needed between the customer mobile app 
    * and the PingOne SDK server.
    */
    public static String generateMobilePayload(Context context)

    /**
    * When using OpenID Connect, this is a mandatory post action method which should be 
    * executed after receiving an id token from the PingOne SDK server.
    *
    * @param idToken:  String
    * @param PingOnePairingCallback:  Will return PingOneSdkError in case of an error. Will 
    * return PairingObject in case further action is required, such as approving the pairing.
    */
    public static void processIdToken(String idToken, PingOnePairingCallback callback)

NotificationObject

/**
* Created by Ping Identity
* Copyright © 2019 Ping Identity. All rights reserved.
* Version 1.1.0
*
* NotificationObject represents an authentication request via remote notification.
* It can be approved or denied.
* Implements Parcelable so the developer will be able to pass it via intents in the application.
*/
public class NotificationObject implements Parcelable {
	
	/**
	* Approve authentication
	* @param context application context
	* @param callback a callback notifies a completion
	* Deprecated in version 1.1.0 please use approve(Context, String, PingOneSDKCallback) instead
	*/
	@Deprecated
	public void approve(Context context, final PingOneSDKCallback callback) ;
	
    /**
	* Approve authentication
	* @param context application context
	* @param authenticationMethod a String representing the authentication method that was used to 
	* authenticate the user on the authenticating device, for example, fpt (fingerprint), 
	* face (facial recognition) etc. Refer to the "amr" (Authentication Method Reference) 
	* values in https://tools.ietf.org/html/rfc8176/#section-2.
	* @param callback a callback notifies a completion
	*/
	public void approve(Context context, String authenticationMethod, final PingOne.PingOneSDKCallback callback);

	/**
	* Denies authentication
	* @param context application context
	* @param callback a callback notifies a completion
	*/
	public void deny(Context context, final PingOneSDKCallback callback);
}

PairingObject

/**
* Created by Ping Identity
* Copyright © 2019 Ping Identity. All rights reserved.
* Version 1.1.0
*
* an object returned if processIdToken flow proposes an automatic pairing
* to allow automatic pairing the developer should trigger the approve method of the object
*/
public class PairingObject implements Parcelable {
	
	/**
	* Approve pairing
	* @param context application context
	* @param callback a callback notifies a completion
	*/
	public void approve(Context context, final PingOneSDKCallback callback);
}

PingOneSDKError

/**
* Class that describes an error by error code and error message
*/
public class PingOneSDKError {
	public int getCode();
	public String getMessage();
}

PingOne Mobile SDK API error codes

Error Status Description
10000 INTERNAL_ERROR Internal Error
10001 DEVICE_TOKEN_IS_MISSING Device token was missing and is required to complete this action
10002 UNRECOGNIZED_REMOTE_NOTIFICATION Remote notification isn’t from PingOne
10003 SERVER_ERROR There was a server error
10004 NO_CONNECTIVITY There was a problem with the network
10005 PAIRING_KEY There was a problem with the pairing key
10006 BUNDLE_ID There was a problem with the application ID
10007 PAIRING_KEY_DATA_CENTER_MISMATCH Device may be paired in one regional data center only, and is already paired in another regional data center.