Skip to main content

Get Started - Android

Initial Setup#

The LoginID Android SDK enables you to add FIDO-certified authentication in your native Android application without having to redirect the user to any pages outside your application.

For more robust functionality, it is likely that you will need to also leverage a Server SDK. The Server SDK makes requests to LoginID's API easier by leveraging your API Credential. Check out the LoginID Server SDK for a simplified integration.

note

The LoginID Android Mobile SDK requires Android 7+ (API 24+) for compatibility.

Create Application on the Dashboard#

An application must be created on the LoginID Dashboard in order to correctly configure the Android SDK.

Once logged into the dashboard, navigate to the Applications tab in the sidebar, select “Add Application,” then select Android.

In the resulting form, you must create a name for your application. We generate a Client ID and Base URL for your application, which you will use to configure the SDK.

After entering your application name, you will be prompted to create an API credential. If you have a client-side only application, please skip this step. Otherwise, create an API credential in order to make protected API calls.

note

An API service token must be included on all requests once an API credential is assigned to an application.

Add SDK to Existing Application#

Import the LoginID package in your Android studio by including our repository and specifying the latest package name and version to be downloaded.

Secondly, add the LoginID maven repository and credentials to your Android main project build.gradle. This will let you add the configuration to the code.

allprojects {
repositories{
google()
jcenter()
// ADD maven repository to download LoginSDK
maven {
url "https://sdk.dev.loginid.io/repository/maven-releases/"
}
}
}

Lastly, add the following packages to your Android app module build.gradle dependencies

implementation 'login.api.native:android-sdk:0.92.24'

Create an SDK Instance#

LoginApi.client().configure(Context context, String clientId, String baseURL)

note

This API must be called before any other APIs. You should call this API within your custom Application's onCreate() method. You can find more information on the process of creating a custom application on Understanding the Android Application Class.

class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
// clientId example 032690b3-9bc4-4602-87c1-60c1fae782f2
val clientId = "<your client id>"
// baseURL example https://060ce487-b934-43d0-a925-b66e80c7532.native-api.auth.company.id
val baseURL = "<your base url>"
LoginApi.client().configure(this,clientId,baseURL)
// any other configurations
...
...
}
}