{"id":18298325,"url":"https://github.com/fusionauth/fusionauth-android-sdk","last_synced_at":"2025-04-05T13:33:17.104Z","repository":{"id":222689528,"uuid":"724073646","full_name":"FusionAuth/fusionauth-android-sdk","owner":"FusionAuth","description":"Android SDK for FusionAuth","archived":false,"fork":false,"pushed_at":"2024-10-29T08:02:07.000Z","size":999,"stargazers_count":3,"open_issues_count":6,"forks_count":1,"subscribers_count":13,"default_branch":"main","last_synced_at":"2024-10-29T08:16:49.026Z","etag":null,"topics":["android","authentication","oauth","oidc"],"latest_commit_sha":null,"homepage":"https://fusionauth.io","language":"CSS","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FusionAuth.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":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-11-27T10:46:04.000Z","updated_at":"2024-10-22T12:10:40.000Z","dependencies_parsed_at":"2024-08-19T10:17:00.401Z","dependency_job_id":"98192ff2-749d-4090-8e7d-ac0e93deda0a","html_url":"https://github.com/FusionAuth/fusionauth-android-sdk","commit_stats":null,"previous_names":["sonderformat-llc/c111-inversoft-mobile-sdk-android","fusionauth/fusionauth-android-sdk"],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FusionAuth%2Ffusionauth-android-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FusionAuth%2Ffusionauth-android-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FusionAuth%2Ffusionauth-android-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FusionAuth%2Ffusionauth-android-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FusionAuth","download_url":"https://codeload.github.com/FusionAuth/fusionauth-android-sdk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223192690,"owners_count":17103564,"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","authentication","oauth","oidc"],"created_at":"2024-11-05T15:05:47.637Z","updated_at":"2025-04-05T13:33:17.093Z","avatar_url":"https://github.com/FusionAuth.png","language":"CSS","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Latest Release Tag](https://badgen.net/github/tag/fusionauth/fusionauth-android-sdk)](https://github.com/FusionAuth/fusionauth-android-sdk/tags)\n[![Dependabot](https://badgen.net/github/dependabot/fusionauth/fusionauth-android-sdk)](https://github.com/FusionAuth/fusionauth-android-sdk/network/updates)\n[![Open PRs](https://badgen.net/github/open-prs/fusionauth/fusionauth-android-sdk)](https://github.com/FusionAuth/fusionauth-android-sdk/pulls)\n\n\nAn SDK for using FusionAuth in Android Apps.\n\n# Table of Contents\n\n- [Overview](#overview)\n\n- [Getting Started](#getting-started)\n\n- [Usage](#usage)\n\n- [Example App](#example-app)\n\n- [Quickstart](#quickstart)\n\n- [Documentation](#documentation)\n\n- [Upgrade Policy](#upgrade-policy)\n\n\u003c!--\nthis and following tags, and the corresponding end tag, are used to delineate what is pulled into the FusionAuth docs site (the client libraries pages). Don't remove unless you also change the docs site.\n\nPlease also use ``` instead of indenting for code blocks. The backticks are translated correctly to adoc format.\n--\u003e\n\n# Overview\n\u003c!--\ntag::forDocSiteOverview[]\n--\u003e\nThis SDK allows you to use OAuth 2.0 and OpenId Connect functionality in an Android app with FusionAuth as the\nauthorization server. It also provides a Token Manager to store, refresh, and retrieve tokens.\n\nIt's a highly standardized and simplified starting point for developers to easily integrate FusionAuth into their own custom mobile apps by taking care of all the dependencies.\n\nThe following OAuth 2.0 and OpenID Connect functionality are covered:\n- OAuth 2.0 Authorization Code Grant\n- OAuth 2.0 Refresh Token Grant\n- OpenID Connect UserInfo\n- OpenID Connect End Session\n\n[AppAuth-Android](https://github.com/openid/AppAuth-Android) is used for the OAuth 2.0 Authorization Code Grant flow and OpenID Connect functionality.\n\nThe SDK is written in Kotlin and is compatible with Java.\n\u003c!--\nend::forDocSiteOverview[]\n--\u003e\n\n# Getting Started\n\n\u003c!--\ntag::forDocSiteGettingStarted[]\n--\u003e\nTo use the FusionAuth Android SDK, add the following dependency to your `build.gradle.kts` file:\n\n```kotlin\ndependencies {\n    implementation('io.fusionauth:fusionauth-android-sdk:\u003clatest-version\u003e')\n}\n```\n\nAfter adding the dependency, you will need to initialize the `AuthorizationManager` with\nthe `AuthorizationConfiguration`:\n\n```kotlin\nAuthorizationManager.initialize(\n    AuthorizationConfiguration(\n        fusionAuthUrl = \"http://10.0.2.2:9011\",\n        clientId = \"e9fdb985-9173-4e01-9d73-ac2d60d1dc8e\",\n        allowUnsecureConnection = true\n    )\n)\n```\n\nThis will initialize the `AuthorizationManager` with the provided `AuthorizationConfiguration`.\nThe `AuthorizationManager` is a singleton and can be accessed from anywhere in your app.\nThe example configuration uses the IP address for your local machine, which is the default for the Android Emulator. If\nyou are running the FusionAuth server on a different machine, you will need to replace the `fusionAuthUrl` with the\ncorrect URL.\n\nInstead of specifying the `AuthorizationConfiguration` in code, you could also read it from a resource file:\n\n```kotlin\nAuthorizationManager.initialize(\n    AuthorizationConfiguration.fromResources(this, R.raw.fusionauth_config)\n)\n```\n\nThe `fusionauth_config.json` file should be placed in the `res/raw` directory and should look like this:\n\n```json\n{\n  \"fusionAuthUrl\": \"http://10.0.2.2:9011\",\n  \"clientId\": \"e9fdb985-9173-4e01-9d73-ac2d60d1dc8e\",\n  \"allowUnsecureConnection\": true\n}\n```\n\nBy default, the SDK uses the `MemoryStorage` for storing tokens. This means that tokens will be lost when the app is\nclosed.\nTo persist tokens, you can use the `SharedPreferencesStorage` or implement your own `TokenStorage`.\n\u003c!--\nend::forDocSiteGettingStarted[]\n--\u003e\n\n# Usage\n\n\u003c!--\ntag::forDocSiteUsage[]\n--\u003e\nTo start the OAuth 2.0 Authorization Code Grant, you can use the `oAuth()` function on the `AuthorizationManager` to\nretrieve the `OAuthAuthorizationService`:\n\n```kotlin\nAuthorizationManager\n    .oAuth(this@LoginActivity)\n    .authorize(\n        Intent(this@LoginActivity, TokenActivity::class.java),\n        OAuthAuthorizeOptions(\n            cancelIntent = Intent(this@LoginActivity, LoginActivity::class.java)\n                .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP),\n            state = \"state-${System.currentTimeMillis()}\"\n        )\n    )\n```\n\nThe `authorize` function will start the OAuth 2.0 Authorization Code Grant flow and open the provided `Intent` when the\nflow is completed.\nThe `OAuthAuthorizeOptions` allows you to specify additional options for the flow, such as the `cancelIntent` and\nthe `state`.\n\nIf the user completes the flow, the `TokenActivity` will be opened, and you are required to handle the redirect:\n\n```kotlin\nAuthorizationManager.oAuth(this@TokenActivity)\n    .handleRedirect(intent)\n```\n\nThis will retrieve the authorization response, validates the `state` if it was provided, and exchanges the authorization\ncode for an access token.\nThe result of the exchange will be stored in the `TokenManager`.\n\nAfter the user is authorized, you can use `getUserInfo()` to retrieve the [User Info](https://openid.net/specs/openid-connect-core-1_0.html#UserInfo):\n\n```kotlin\nAuthorizationManager.oAuth(this@TokenActivity).getUserInfo()\n```\n\nTo call your API with an access token, you can use the `AuthorizationManager` to retrieve a valid access token:\n\n```kotlin\nval accessToken = AuthorizationManager.freshAccessToken(this@TokenActivity)\n```\n\nThis will retrieve a fresh access token from the `TokenManager` and return it. If the access token is expired,\nthe `TokenManager` will refresh it automatically.\n\nFinally, you can use the `AuthorizationManager` to sign out the user and remove the tokens from the `TokenManager`:\n\n```kotlin\nAuthorizationManager\n    .oAuth(this@TokenActivity)\n    .logout(\n        Intent(this@TokenActivity, LoginActivity::class.java)\n            .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)\n    )\n```\n\nIf the user is signed out, the `LoginActivity` will be opened.\n\u003c!--\nend::forDocSiteUsage[]\n--\u003e\n\n# Example App\n\n\u003c!--\ntag::forDocSiteExampleApp[]\n--\u003e\nSee the [FusionAuth Android SDK Example](https://github.com/FusionAuth/fusionauth-quickstart-kotlin-android-native) for a functional example of an Android client that uses the SDK.\n\u003c!--\nend::forDocSiteExampleApp[]\n--\u003e\n\n# Quickstart\n\n\u003c!--\ntag::forDocSiteQuickstart[]\n--\u003e\nSee the [FusionAuth Android Quickstart](https://fusionauth.io/docs/quickstarts/quickstart-kotlin-android-native) for a full tutorial on using FusionAuth and Android.\n\u003c!--\nend::forDocSiteQuickstart[]\n--\u003e\n\n# Documentation\n\n\u003c!--\ntag::forDocSiteDocumentation[]\n--\u003e\nSee the latest [Full library documentation](https://github.com/FusionAuth/fusionauth-android-sdk/blob/main/library/docs/index.md) for the complete documentation of the SDK.\n\u003c!--\nend::forDocSiteDocumentation[]\n--\u003e\n\n# Contributing\n\u003c!--\ntag::forDocSiteContributing[]\n--\u003e\nWe hope you love using FusionAuth Android SDK, but in case you encounter a bug or an issue with the SDK, please do let us know.\n\nPlease follow the detailed [Contributing](CONTRIBUTING.md) documentation.\n\u003c!--\nend::forDocSiteContributing[]\n--\u003e\n\n# Upgrade Policy\n\nThis library may periodically receive updates with bug fixes, security patches, tests, code samples, or documentation changes.\n\nThese releases may also update dependencies, language engines, and operating systems, as we\\'ll follow the deprecation and sunsetting policies of the underlying technologies that the libraries use.\n\nThis means that after a dependency (e.g. language, framework, or operating system) is deprecated by its maintainer, this library will also be deprecated by us, and may eventually be updated to use a newer version.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffusionauth%2Ffusionauth-android-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffusionauth%2Ffusionauth-android-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffusionauth%2Ffusionauth-android-sdk/lists"}