{"id":22268153,"url":"https://github.com/curityio/android-haapi-demo-app","last_synced_at":"2025-04-11T18:53:24.041Z","repository":{"id":43379457,"uuid":"298594142","full_name":"curityio/android-haapi-demo-app","owner":"curityio","description":"An OpenID Connect Android demo app showing how to plug in the HAAPI Model SDK","archived":false,"fork":false,"pushed_at":"2024-01-05T09:39:09.000Z","size":1368,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-25T14:46:01.542Z","etag":null,"topics":["android","code-example","haapi","mobile","oauth2","openid-connect"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/curityio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-09-25T14:20:49.000Z","updated_at":"2025-01-01T13:29:36.000Z","dependencies_parsed_at":"2024-01-05T10:45:57.357Z","dependency_job_id":"53d8fe51-19c4-4438-867e-960fd29d81a0","html_url":"https://github.com/curityio/android-haapi-demo-app","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/curityio%2Fandroid-haapi-demo-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/curityio%2Fandroid-haapi-demo-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/curityio%2Fandroid-haapi-demo-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/curityio%2Fandroid-haapi-demo-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/curityio","download_url":"https://codeload.github.com/curityio/android-haapi-demo-app/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248464479,"owners_count":21108238,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","code-example","haapi","mobile","oauth2","openid-connect"],"created_at":"2024-12-03T11:11:42.294Z","updated_at":"2025-04-11T18:53:24.013Z","avatar_url":"https://github.com/curityio.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Demo Android application which uses HAAPI\n\n[![Quality](https://img.shields.io/badge/quality-demo-red)](https://curity.io/resources/code-examples/status/)\n[![Availability](https://img.shields.io/badge/availability-source-blue)](https://curity.io/resources/code-examples/status/)\n\nThis is an example Android app which uses the Curity Identity Server's Hypermedia API to perform an\nOAuth2 flow with authentication done completely from the app, without the need of an external browser.\n\nNote: The app needs at least Android 8.0 (*Oreo*, API level 26) to properly use the attestation features.\nYou will need the Curity Identity Server at least in version 5.4. to work with this app.\n\n## Getting started\n\nNote that gradle tasks require at least Java 11 to run properly. Make sure to have the proper Java SDK\nversion set in `Preferences / Build,Execution,Deployment / Build Tools / Gradle / Gradle JDK` in Android Studio.\n\n### Docker Automated Setup\n\nThe required Curity Identity Server setup and connectivity from devices can be automated via a bash script:\n\n1. Copy a license.json file into the code example root folder.\n2. Run the `./start-idsvr.sh` script to deploy a preconfigured Curity Identity Server via Docker. \n3. Build and run the mobile app from Android Studio using an emulator of your choice.\n4. There is a preconfigured user account you can sign-in with: demouser / Password1. Feel free to create additional accounts.\n5. Run the `./stop-idsvr.sh` script to free Docker resources.\n\nBy default the Curity Identity Server instance runs on the the Android emulator's default host IP. \nIf you prefer to expose the Server on the Internet (e.g. to test with a real device), you can use the \nngrok tool for that. Edit the `USE_NGROK` variable in `start-server.sh` and `stop-server.sh` scripts.\nThis [Mobile Setup](https://curity.io/resources/learn/mobile-setup-ngrok/) tutorial further describes\nthis option.\n\n### Setting up with Your Own Instance of the Curity Identity Server\n\nYou can install and run your own instance of the Curity Identity Server by following this tutorial: https://curity.io/resources/getting-started/ \n\nOnce installed you can easily configure the server by uploading the provided configuration file.\n❗️When applying the provided configuration to your identity server, you will be able to run directly the demo application on the emulator. \n\nTo upload the configuration, follow these steps:\n1. Login to the admin UI (https://localhost:6749/admin if you're using defaults).\n2. Upload `curity-android-config.xml` through the **Changes**-\u003e**Upload** menu at the top. (Make sure to use the `Merge` option)\n3. Commit changes through the **Changes**-\u003e**Commit** menu.\n\n## Testing the demo app against your identity server\n\n### Emulator\n\n1. Make sure that the Curity Identity Server is running and configured.\n2. Start the demo application on an emulator that has Android API level equal to or larger than 26.\n3. Tap the button `Start Authentication`.\n\n### Physical device (API level \u003e= 26)\n\n1. Make sure that the Curity Identity Server is running and configured to be reachable on the Internet (e.g. by using [ngrok](https://curity.io/resources/learn/expose-local-curity-ngrok/)).\n2. Start the demo application on your physical device.\n4. Tap Settings in the tab navigation bar of the app.\n5. Edit a configuration to target your instance of the Curity Identity Server. If you are using `curity-android-config.xml`,\n   you need to replace https://10.0.2.2:8443 with the identity server URL.\n6. Tap `Home` in the tab navigation.\n7. Tap the button `Start Authentication`.\n\n## How to get the API Signature ?\n\nUse the signingReport task (`./gradlew SigningReport`) to get the app signature. You can copy the `SHA-256` signature and paste it in the signature field\nin the admin UI (on your client's settings page). If you want to paste the signature into an XML file, or use the CLI or RestConf API to add the signature,\nthen you need to use a base64 version of the signature hash. You can run this command to obtain the encoded signature:\n\n```shell\necho \"\u003csha-256 signature from the signingReport\u003e\" | xxd -r -p | base64\n```\n\nIf you're running the demo app on a device with an API version \u003e= API 28 (Android 9.0, Pie), then when \nstarting the application, in Logcat, you should the APK Signature printed in DEBUG mode.\n\n`2021-07-14 12:22:37.952 9631-9631/io.curity.haapidemo D/AppInfo: APK signatures $RESULT$`\n\n## Configuring the App\n\nThe application needs a few configuration options set to be able to call the instance of the Curity Identity Server.\nDefault configuration is set to work with the dockerized version of the Curity Identity Server which\nis run with the `start-idsvr.sh` script. Should you need to make the app work with a different environment\n(e.g. you have your instance of the Curity Identity Server already working online), then you can adjust\nthe configuration in two ways:\n\n1. You can edit the default settings in the `src/main/java/io/curity/haapidemo/Configuration.kt` file.\n   The default settings are returned by the static `newInstance` method, and this is the one that should\n   be modified.\n\n2. You can update settings directly in the running app. When on the home screen of the app you can tap\n   the settings icon. There you will be able to create and edit configuration profiles. You can then\n   switch the active profile to quickly test between different environments of the Curity Identity Server.\n\n## Resources\n\n- [Introduction](https://curity.io/resources/learn/what-is-hypermedia-authentication-api/)\n  to the Hypermedia Authentication API.\n\n- [An article](https://curity.io/resources/learn/authentication-api-android-sdk)\n  showing how to properly configure the Curity Identity Server and a client to use the Hypermedia\n  API from an Android app.\n\n## Docker Automated Setup\n\nThe above Curity Identity Server setup and connectivity from devices can be automated via a bash script:\n\n- Copy a license.json file into the code example root folder\n- Edit the `./start-idsvr.sh` script to use either a local Docker URL on an ngrok internet URL\n- Run the script to deploy a preconfigured Curity Identity Server via Docker\n- Build and run the mobile app from Android Studio\n- Sign in with the preconfigured user account `demouser / Password1`\n- Edit the `./stop-idsvr.sh` script to use matching ngrok settings to the start script\n- Run the script to free Docker resources\n\nThe [Mobile Setup](https://curity.io/resources/learn/mobile-setup-ngrok/) article provides further details on this setup.\n\n## More information\n\nFor further details about this code example, see the [Tutorial Walkthrough](https://curity.io/resources/learn/kotlin-android-haapi/) on the Curity website.\\\nPlease visit [curity.io](https://curity.io/) for more information about the Curity Identity Server.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcurityio%2Fandroid-haapi-demo-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcurityio%2Fandroid-haapi-demo-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcurityio%2Fandroid-haapi-demo-app/lists"}