# Identification

## Example to Start an Identification

Start the identification process by calling `IdentificationActivity.startForResult` in your activity. &#x20;

Please update the below code with your Client ID and Client Secret from your [Customer Dashboard](https://customer-dashboard.app.authenteq.com/sign-in). To support multiple documents and other flow settings also use the Customer Dashboard.&#x20;

Flow ID specify which verification flow to use. Flow IDs are defined in the Customer Dashboard, section Verification Flow.

This method internally prepares `Intent` for the identification process and starts an activity:

{% tabs %}
{% tab title="Java" %}

```java
IdentificationParams params = new IdentificationParamsWithClientSecret(
        "< client id >",
        "< client secret >",
        "< flow ID >", // optional
        R.style.AuthenteqThemeBase // optional
);

IdentificationActivity.startForResult(
    activity, 
    MY_REQUEST_CODE,
    params
);
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
val parameters = IdentificationParamsWithClientSecret(
        "< client id >",
        "< client secret >",
        R.style.AuthenteqThemeBase // optional
)

IdentificationActivity.startForResult(
    activity,
    REQUEST_CODE_IDENTIFICATION,
    params
)
```

{% endtab %}
{% endtabs %}

Optionally you can specify a custom style, for more information see the section [Customization](https://docs.authenteq.com/mo/android/customization).

## Start an Identification providing authentication Token

Identification can be started by providing the authentication token obtained separately (see section [Authentication Token](https://docs.authenteq.com/mo/authentication-token) for details).

The optional "*Flow ID*" can be specified when requesting the authentication token.

To start an identification with a token create an `IdentificationParamsWithToken` object and use it in the `IdentificationActivity.startForResult` : �

{% tabs %}
{% tab title="Java" %}

```java
IdentificationParams params = new IdentificationParamsWithToken(
        "< client id >",
        "< token >",
        R.style.AuthenteqThemeBase // optional
);

IdentificationActivity.startForResult(
        fragment,
        REQUEST_CODE_IDENTIFICATION,
        params
);
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
val parameters = IdentificationParamsWithToken(
        "< client id >",
        "< token >",
        R.style.AuthenteqThemeBase // optional
)

IdentificationActivity.startForResult(
        activity,
        REQUEST_CODE_IDENTIFICATION,
        parameters
)
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
Authentication token can only be used for a single verification. Always generate a new token before start a new verification.
{% endhint %}

## Identification completion

`onActivityResult`  will be called in your activity after on-boarding is either finished or canceled.  Here you can get the on-boarding result and process it:

{% tabs %}
{% tab title="Java" %}

```java
@Override 
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
    if (requestCode == MY_REQUEST_CODE) {
        if (resultCode == RESULT_OK) {
            final IdentificationResult resul = IdentificationActivity.getResult(data)
            // process onboarding result
        } else {
            // process is canceled by user
            final Throwable error = IdentificationActivity.getError(data);
            if(error != null) {
                // process error
            }               
        }
    } else {
        super.onActivityResult(requestCode, resultCode, data);
    }
}
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
override fun onActivityResult(
    requestCode: Int,
    resultCode: Int,
    data: Intent?) 
{
    if (requestCode == REQUEST_CODE_IDENTIFICATION) {
        if (data == null) return
        if (resultCode == Activity.RESULT_OK) {
            IdentificationActivity.getResult(data)?.let { result ->
                // process onboarding result
            }
        } else {
            IdentificationActivity.getError(data)?.let { error ->
                // process error
            }
        }
    } else {
        super.onActivityResult(requestCode, resultCode, data)
    }
}
```

{% endtab %}
{% endtabs %}
