> For the complete documentation index, see [llms.txt](https://docs.uaepass.ae/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.uaepass.ae/feature-guides/authentication/mobile-application/guide/sdk/android.md).

# Android

**Quick Setup**

1. Open `SampleApp/` in Android Studio.
2. Ensure the library exists at:
   * `SampleApp/app/libs/UAE-PASS-Android-Library-release.aar`
3. Verify `SampleApp/app/build.gradle` includes:
   * `implementation files('libs/UAE-PASS-Android-Library-release.aar')`
4. Configure your values in `SampleApp/app/build.gradle`:
   * `CLIENT_ID`
   * `CLIENT_ID_FACE_VERFICATION`
   * `REDIRECT_URL`
   * `URI_SCHEME` (must be unique; do not keep the sample value)
5. Make sure `manifestPlaceholders.scheme` matches `URI_SCHEME`.

**#Mandatory First Flow (Do This First)**

**Before profile or signing actions, complete this sequence:**

1. Select environment in the app ( `STAGING`, `PRODUCTION`).
2. Tap **Get Access Code**.
3. Send the returned access code to your backend.
4. Backend exchanges code for token and returns token to app.
5. Paste token in the **Access Token** field.
6. Tap **Submit Access Token**.

**Environment Mapping**&#x20;

The selected environment must match the UAE Pass app installed on the device:

* `PRODUCTION` -> `ae.uaepass.mainapp`
* `STAGING` -> `ae.uaepass.mainapp.stg`

\#***Use the correct token for each operation.***

#### 1) User Access Token (Profile)

* Obtained by backend after exchanging login access code.
* Used for profile retrieval (`getUserProfile`).

#### 2) Signing Token (Client Credentials)

* Obtained by backend using client credentials and signing scope.
* Used for document signing and signed-document download.
* This token is different from the profile/user token.

### Get User Profile

After submitting a valid **User Access Token**:

1. Tap **Get User Profile**.
2. App calls `UAEPassController.getUserProfile(...)`.

### Document Signing Flow

#### Prerequisites

* Use sample PDF from assets (`dummy.pdf`) or your own PDF.
* Ensure signing payload JSON is valid.
* Ensure signing token is pasted and submitted.

#### Signing Steps

1. Paste signing token in **Access Token** field.
2. Tap **Submit Access Token**.
3. Tap one of:
   * **Sign Document** (advanced)
   * **Sign Document (Qualified)**
4. Complete UAE Pass authentication in app or WebView.
5. App receives `documentURL` in callback.
6. App downloads signed PDF via `downloadDocument(...)` and saves it to Downloads.

### Signing Payload Files

* `SampleApp/app/src/main/assets/testSignData.json`
* `SampleApp/app/src/main/assets/testSignDataQualified.json`

Ensure `finish_callback_url` matches your app scheme:

```json
"finish_callback_url": "yourappscheme://sign"
```

For qualified signature flow, use `testSignDataQualified.json`.

### Reset / Logout

Use the **Reset** button to clear local session data:

* Clears stored access token (`UAEPassController.clearAccessToken()`)
* Clears WebView cookies
* Clears token input and access code label in UI

### Run the Sample

From project root `SampleApp/`:

```zsh
./gradlew clean
./gradlew assembleDebug
```

Then install and run from Android Studio or with ADB.

**Main Files to Review**

* `SampleApp/app/src/main/java/ae/sdg/uaepasssample/MainActivity.kt`
* `SampleApp/app/src/main/java/ae/sdg/uaepasssample/UAEPassRequestModels.kt`
* `SampleApp/app/src/main/assets/testSignData.json`
* `SampleApp/app/src/main/assets/testSignDataQualified.json`
* `TECHNICAL_DOCUMENTATION.md`

<mark style="color:$success;">**Note :**</mark>&#x20;

* Submit Access Token does not call UAE Pass APIs.
* It only stores the token using `UAEPassController.setAccessToken(...)` for later calls.
