Authenticate the user by login and password

To execute user authentication on mobile platform server by login and password, create the AuthenticationActivity application, which uses the auth method implemented in the AuthAPI unit.

The AuthenticationActivity application includes one screen and a button:

To view application work results, use the interactive example:

Click the AUTHENTICATION button.

public class AuthenticationActivity extends AppCompatActivity {
   // Copy credentials from the administrator console into variables
   private static final String MY_URL = "https://testmasterfmp.fsight.cloud/";
   private static final VersionAPI MY_VERSION_API = VersionAPI.V_1;
   private static final String MY_ENVIRONMENT = "Leonid_environment"; // environment name
   private static final String MY_PROJECT = "Leonid_project"; // project name
   private static final String MY_VERSION = "v1";
   private static final String MY_LOGIN = "Leonid"; // login
   private static final String MY_PASSWORD = "123123"; // password
   private static final String TAG = "AuthenticationActivity";
 
   private HyperHive hyperHive;
 
   @Override
   protected void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_auhtentication);
 
       Handler uiHandler = new Handler();
 
       // Insert declared variables into methods
       hyperHive = new HyperHiveState(getApplicationContext())
               .setHostWithSchema(MY_URL)
               .setApiVersion(MY_VERSION_API)
               .setEnvironmentSlug(MY_ENVIRONMENT)
               .setProjectSlug(MY_PROJECT)
               .setVersionProject(MY_VERSION)
               .setHandler(uiHandler)
               .buildHyperHive();
   }
 
   // Execute authentication method
   public void authentication(View view) {
       // Pass login and password
       boolean status = hyperHive.authAPI.auth(MY_LOGIN, MY_PASSWORD, true).execute().isOk();
       showStatus(status);
   }
 
   public void showStatus(boolean status) {
       Log.d(TAG, "auth: " + status);
       Toast.makeText(this, "auth: " + status, Toast.LENGTH_LONG).show();
   }
}

See. also:

Examples of Authentication on Mobile Platform Server | User Authentication with Password Change