Change PIN

Changing PIN

The UserClient offers a method to change PIN for currently logged in user profile. This methods is called changePin and requires one argument:

  • OneginiChangePinHandler the changed PIN handler to return the result of change PIN action.

The SDK will handle flow of changing the PIN using OneginiPinAuthenticationRequestHandler and OneginiCreatePinRequestHandler handlers. Please read PIN authenticator topic guide to learn how to implement those two handlers and how to cancel PIN change process.

Handler methods

  • void onSuccess() is called when PIN was changed.

  • void onError(final OneginiChangePinError oneginiChangePinError) is called when some error during changing PIN occurred.

Example code for changing PIN

  public void startChangePinFlow() {
    OneginiSDK.getOneginiClient(this).getUserClient().changePin(new OneginiChangePinHandler() {
      public void onSuccess() {
        showToast("Change PIN action finished successfully");

      public void onError(final OneginiChangePinError oneginiChangePinError) {
        @OneginiChangePinError.ChangePinErrorType int errorType = oneginiChangePinError.getErrorType();
        if (errorType == OneginiChangePinError.USER_DEREGISTERED) {
        } else if (errorType == OneginiChangePinError.DEVICE_DEREGISTERED) {
          new DeregistrationUtil(SettingsActivity.this).onDeviceDeregistered();

  private void userDeregistered() {
    final Intent intent = new Intent(this, LoginActivity.class);

    UserProfile authenticatedUserProfile = OneginiSDK.getOneginiClient(SettingsActivity.this).getUserClient().getAuthenticatedUserProfile();
    if (authenticatedUserProfile == null) {
    new DeregistrationUtil(this).onUserDeregistered(authenticatedUserProfile);

For more info on error handling see the error handling topic guide.

As you can see in the example above we handle only one error case - when user got deregistered (probably due to too many failure PIN attempts). Please note that you can handle errors that are relevant to you differently. To accomplish that you should compare the OneginiChangePinError#getErrorType() value with the OneginiChangePinError error type definitions. The OneginiChangePinError will also contain an additional error description for debugging and possibly a Throwable object which you can get with the getMessage() and getCause() methods.