private void attemptRegistration() {
    CredentialsClient credentialsClient = sso.getCredentialsClient(clientCredentialsTokens);

    firstNameField = (EditText) getView().findViewById(R.id.first_name);

    CreateAccountParams createAccountParams =
        new CreateAccountParams.Builder()
            .addDefaultScopes()
            .setEmail(emailField.getText().toString())
            .setFirstName(firstNameField.getText().toString())
            .setPassword(passwordField.getText().toString())
            .build();

    credentialsClient.createAccount(
        createAccountParams,
        new EndpointAsyncResponseHandler<CreateAccountResponse>(CreateAccountResponse.class) {
          @Override
          public void onSuccess(CreateAccountResponse response) {
            TokenSet tokenSet = response.getTokenSet(standardConfiguration);
            log(
                "Successfully created a new account and received the token set: ",
                tokenSet.toString());
            fetchMeDetails(tokenSet);
          }

          @Override
          public void onFailure(EndpointCallbackException result) {
            log("Failed to create a new account: ", result.getMessage());
          }
        });
  }
  private void checkPassword() {
    CredentialsClient credentialsClient = sso.getCredentialsClient(clientCredentialsTokens);

    credentialsClient.checkPassword(
        passwordField.getText().toString(),
        new EndpointAsyncResponseHandler<CheckPasswordResponse>(CheckPasswordResponse.class) {
          @Override
          public void onSuccess(CheckPasswordResponse response) {
            if (response.isAccepted()) {
              log("The password is valid, proceeding...");
              attemptRegistration();
            } else {
              log("The provided password is not valid: ", response.toString());
            }
          }

          @Override
          public void onFailure(EndpointCallbackException result) {
            log("Failed to validate the password: ", result.getMessage());
          }
        });
  }
  private void checkMail() {
    // hide the keyboard first
    InputMethodManager inputManager =
        (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);

    inputManager.hideSoftInputFromWindow(
        getView().getWindowToken(), InputMethodManager.RESULT_UNCHANGED_SHOWN);

    CredentialsClient credentialsClient = sso.getCredentialsClient(clientCredentialsTokens);

    emailField = (EditText) getView().findViewById(R.id.email);

    CheckMailParams checkMailParams =
        new CheckMailParams.Builder().setEmail(emailField.getText().toString()).build();

    credentialsClient.checkMail(
        checkMailParams,
        new EndpointAsyncResponseHandler<CheckMailResponse>(CheckMailResponse.class) {
          @Override
          public void onSuccess(CheckMailResponse response) {

            if (response.isAvailable()) {
              log("The email address is available, proceeding...");
              checkPassword();
            } else {
              log("The email address is NOT available because: ", response.getError());
            }

            if (response.getSuggestion() != null) {
              log("An email address suggestion: ", response.getSuggestion());
            }
          }

          @Override
          public void onFailure(EndpointCallbackException result) {
            log("Failed to validate the email address: ", result.getMessage());
          }
        });
  }