Example of Authentication at Mobile Platform Server

To execute authentication at mobile platform server, 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:

Tap the AUTHENTICATION button.

public class AuthenticationActivity extends AppCompatActivity {
   //1. 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();
   }
 
   //2. Execute authentication method
   public void authentication(View view) {
       // Send 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 Android Framework Use