Search Results for

    Show / Hide Table of Contents

    Connect an Android Mobile App

    Android applications can authenticate using The Identity Hub. This can be done using one of the Authentication Endpoints like OAuth, OpenID Connect... or using the Android SDK.

    SDK and Demo App.

    A preconfigured SDK can be downloaded from the App Configurations Details page.

    Or download the non-configured SDK from here.

    A demo app can be found here.

    Installing the SDK

    1. Download the SDK from the App Configurations Details page or download the non-configured SDK from here.
    2. To integrate the com.theidentityhub with your Android Project in Eclipse extract it into your workspace folder and import it in Eclipse (File | Import | General | Existing Projects into Workspace | Select root directory: [FOLDER WHERE YOU HAVE EXTRACTED] | Finish).
    3. After you have imported Project Explorer will show imported project under the name TheIdentityHubLibrary. Make sure you keep open TheIdentityHubLibrary.
    4. To start using TheIdentityHubLibrary in your Android Application project you have to modify properties in your Android Application project.
    5. Select your Android Application project in Project Explorer. Open the properties (File | Properties).
      1. On the left tree select Android.
      2. In the right panel in a Library frame click Add�
      3. Select TheIdentityHubLibrary project and then click OK.
      4. Click OK the Properties dialog.
      5. Your Android Application project is ready to use TheIdentityHubLibrary.

    Initialize the Identity Service

    Inside the activity in some of your event triggered methods set configuration parameters:

    // Your ClientId
    String CLIENT_ID = "[ClientId]";
    // Your base URL
    String BASE_URL = "https://www.theidentityhub.com/{tenant}";
    // Initialize
    IdentityService is = new IdentityService (CLIENT_ID, BASE_URL);
    

    Authenticate

        is.tryAuthenticate(MainActivity.this);
                // Use handler to check when authentication is completed
    	final Handler h = new Handler();
    	h.postDelayed(new Runnable() {
    		@Override
    		public void run() {
    			if (is.isAuthenticated()) {
    				// If authenticated stop the handler callbacks
    				h.removeCallbacks(this);
    				// Continue
    			}else {
    				// If not check again in 5 seconds
    				h.postDelayed(this, 5 * 1000);
    			}
    		}
    	}, 5*1000);
    

    Getting Profile Information

    Profile profile = is.getProfile();
    

    Getting information on the current user's friends

    ArrayList<Friend> friends = is.getFriends();
    

    Getting information on the current user's accounts

    ArrayList<AccountProvider> accountProviders = is.getAccounts();
    

    Getting information on the current user's roles

    ArrayList<Role> roles = is.getRoles();
    
    In This Article