{"id":15046787,"url":"https://github.com/auth0/lock.android","last_synced_at":"2025-05-16T04:07:06.523Z","repository":{"id":24069862,"uuid":"27456226","full_name":"auth0/Lock.Android","owner":"auth0","description":"Android Library to authenticate using Auth0 and with a Native Look \u0026 Feel","archived":false,"fork":false,"pushed_at":"2025-01-27T02:17:57.000Z","size":6650,"stargazers_count":145,"open_issues_count":6,"forks_count":82,"subscribers_count":54,"default_branch":"main","last_synced_at":"2025-05-16T04:07:00.627Z","etag":null,"topics":["android","dx-sdk","hacktoberfest","lock"],"latest_commit_sha":null,"homepage":"https://auth0.com/lock","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/auth0.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-12-02T22:13:43.000Z","updated_at":"2025-02-11T09:56:52.000Z","dependencies_parsed_at":"2023-10-04T23:03:37.192Z","dependency_job_id":"9c382ca1-c351-4dd8-bc7b-080d39f3169d","html_url":"https://github.com/auth0/Lock.Android","commit_stats":null,"previous_names":[],"tags_count":84,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auth0%2FLock.Android","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auth0%2FLock.Android/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auth0%2FLock.Android/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auth0%2FLock.Android/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/auth0","download_url":"https://codeload.github.com/auth0/Lock.Android/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254464897,"owners_count":22075571,"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","dx-sdk","hacktoberfest","lock"],"created_at":"2024-09-24T20:53:34.932Z","updated_at":"2025-05-16T04:07:01.514Z","avatar_url":"https://github.com/auth0.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003e **Note**\n\u003e As part of our ongoing commitment to best security practices, we have rotated the signing keys used to sign previous releases of this SDK. As a result, new patch builds have been released using the new signing key. Please upgrade at your earliest convenience.\n\u003e\n\u003e While this change won't affect most developers, if you have implemented a dependency signature validation step in your build process, you may notice a warning that past releases can't be verified. This is expected, and a result of the key rotation process. Updating to the latest version will resolve this for you.\n\n![Lock for Android](https://cdn.auth0.com/website/sdks/banners/lock-android-banner.png)\n\n[![CircleCI](https://circleci.com/gh/auth0/Lock.Android.svg?style=shield)](https://circleci.com/gh/auth0/Lock.Android)\n[![License](https://img.shields.io/dub/l/vibe-d.svg?style=flat)](https://opensource.org/licenses/MIT)\n[![Maven Central](https://img.shields.io/maven-central/v/com.auth0.android/lock.svg)](https://search.maven.org/#search%7Cga%7C1%7Cg%3A%22com.auth0.android%22%20AND%20a%3A%22lock%22)\n\n📚 [Documentation](#documentation) • 🚀 [Getting Started](#getting-started) • ⏭️ [Next Steps](#next-steps) • 💬 [Feedback](#feedback)\n\n## Documentation\n\n- [Examples](https://github.com/auth0/Lock.android/blob/main/EXAMPLES.md)\n- [Docs Site](https://auth0.com/docs/libraries/lock-android)\n- [API Reference](https://javadoc.io/doc/com.auth0.android/lock/latest/index.html)\n\n## Getting Started\n\n### Requirements\n\nAndroid API Level 21+ \u0026 Java version 8 or above is required in order to use Lock's UI.\n\nHere’s what you need in build.gradle to target Java 8 byte code for the Android and Kotlin plugins respectively.\n\n```groovy\nandroid {\n    compileOptions {\n        sourceCompatibility JavaVersion.VERSION_1_8\n        targetCompatibility JavaVersion.VERSION_1_8\n    }\n\n    kotlinOptions {\n        jvmTarget = '1.8'\n    }\n}\n```\n\n### Installation\n\nLock is available in [Maven Central](http://search.maven.org). To start using *Lock* add this line to the dependencies of your `build.gradle` file:\n\n```groovy\nimplementation 'com.auth0.android:lock:3.2.2'\n```\n\n## Next Steps\n\nIf you haven't done yet, go to [Auth0](https://auth0.com) and create an Account, it's free! Then create a new [Application](https://manage.auth0.com/#/applications) of type *Native* and add a URL in *Allowed Callback URLs* with the following format:\n\n```\nhttps://{YOUR_AUTH0_DOMAIN}/android/{YOUR_APP_PACKAGE_NAME}/callback\n```\n\nThe *package name* value required in the Callback URL can be found in your app's `build.gradle` file in the `applicationId` property. Both the *domain* and *client id* values can be found at the top of your Auth0 Application's settings. You're going to use them to setup the SDK. It's good practice to add them to the `strings.xml` file as string resources that you can reference later from the code. This guide will follow that practice.\n\n```xml\n\u003cresources\u003e\n    \u003cstring name=\"com_auth0_client_id\"\u003eYOUR_AUTH0_CLIENT_ID\u003c/string\u003e\n    \u003cstring name=\"com_auth0_domain\"\u003eYOUR_AUTH0_DOMAIN\u003c/string\u003e\n\u003c/resources\u003e\n```\n\nIn your `app/build.gradle` file add the **Manifest Placeholders** for the Auth0 Domain and Auth0 Scheme properties, which are going to be used internally by the library to declare the Lock activities and register **intent-filters** that will capture the authentication result.\n\n```groovy\napply plugin: 'com.android.application'\n\nandroid {\n    compileSdkVersion 30\n    defaultConfig {\n        applicationId \"com.auth0.samples\"\n        minSdkVersion 21\n        targetSdkVersion 30\n        //...\n\n        //---\u003e Add the next line\n        manifestPlaceholders = [auth0Domain: \"@string/com_auth0_domain\", auth0Scheme: \"https\"]\n        //\u003c---\n    }\n    //...\n}\n```\n\nThe next step is to create an instance of `Auth0` with your application's information. The easiest way to create it is by using the values defined previously in the `strings.xml` file and passing an Android Context. For this to work, you must have defined the string resources using the same keys as listed above.\n\n```kotlin\nval account = Auth0(context)\n```\n\nAlternatively, you can directly pass the values.\n\n```kotlin\nval account = Auth0(\"{YOUR_AUTH0_CLIENT_ID}\", \"{YOUR_AUTH0_DOMAIN}\")\n```\n\nOr, if you are using _custom domains_ and are required to specify a different URL to fetch the Lock widget configuration from, you can use the constructor that takes 3 parameters:\n\n```kotlin\nval account = Auth0(\"{YOUR_AUTH0_CLIENT_ID}\", \"{YOUR_AUTH0_DOMAIN}\", \"{THE_CONFIGURATION_DOMAIN}\")\n```\n\n\n### Email/Password, Enterprise \u0026 Social authentication\n\nInitialize **Lock** and handle the release of its resources appropriately after you're done using it. \n\n```kotlin\n// This activity will show Lock\nclass MyActivity : AppCompatActivity() {\n\n    private lateinit var lock: Lock\n\n    override fun onCreate(savedInstanceState: Bundle?) {\n        super.onCreate(savedInstanceState)\n    \n        val account = Auth0(this)\n        // Instantiate Lock once\n        lock = Lock.newBuilder(account, callback)\n            // Customize Lock\n            .build(this)\n    }\n    \n    override fun onDestroy() {\n        super.onDestroy()\n        // Important! Release Lock and its resources\n        lock.onDestroy(this)\n    }\n    \n    private val callback = object : AuthenticationCallback() {\n        override fun onAuthentication(credentials: Credentials) {\n            // Authenticated\n        }\n        \n        override fun onError(error: AuthenticationException) {\n            // An exception occurred\n        }\n    }\n}\n```\n\nStart `LockActivity` from inside your `Activity`. For this, create a new intent from the Lock instance and launch it.\n\n```kotlin\nstartActivity(lock.newIntent(this))\n```\n\n### Customizing the widget\n\nWhen using the `Builder` to instantiate the widget, you can pass different options to customize how it will behave. Some options are only available for **Lock** or **PasswordlessLock**. Below you will find a few of them. You can always explore all the available options with your IDE's auto-complete shortcut. Check the Javadocs to understand the default values.\n\n\n```kotlin\n// Create a new builder from Lock or LockPasswordless classes\nnewBuilder(account, callback)\n    // Shared options\n    .closable(true) // Allows the widget to be closed with the back button\n    .withScope('new-scope') // Changes the scope to be requested on authentication\n    .withAudience('my-api') // Changes the audience to be requested on authentication\n    .withScheme('myapp') // Changes the scheme part used to generate the Callback URL (more below)\n    \n    // Lock specific options\n    .initialScreen(InitialScreen.SIGN_UP) // Allows to choose the screen to be displayed first \n    .allowLogIn(false) // Disables the Log In screen\n    .allowSignUp(false) // Disables the Sign Up screen\n    .allowForgotPassword(false) // Disables the Change Password screen\n    .setDefaultDatabaseConnection('my-connection') // When multiple are available, select one\n    \n    // PasswordlessLock specific options\n    .useCode(true)  // Requests to receive a OTP that will need to be filled in your android app to authenticate the user\n    .useLink(false) // Requests to receive a link that will open your android app to authenticate the user\n    .rememberLastLogin(true) // Saves the email or phone number to avoid re-typing it in the future\n    \n    // Build the instance\n    .build(this)\n```\n\n## Feedback\n\n### Contributing\n\nWe appreciate feedback and contribution to this repo! Before you get started, please see the following:\n\n- [Auth0's general contribution guidelines](https://github.com/auth0/open-source-template/blob/master/GENERAL-CONTRIBUTING.md)\n- [Auth0's code of conduct guidelines](https://github.com/auth0/open-source-template/blob/master/CODE-OF-CONDUCT.md)\n\n### Raise an issue\nTo provide feedback or report a bug, [please raise an issue on our issue tracker](https://github.com/auth0/Lock.Android/issues).\n\n### Vulnerability Reporting\nPlease do not report security vulnerabilities on the public Github issue tracker. The [Responsible Disclosure Program](https://auth0.com/whitehat) details the procedure for disclosing security issues.\n\n---\n\n\u003cp align=\"center\"\u003e\n  \u003cpicture\n    \u003csource media=\"(prefers-color-scheme: light)\" srcset=\"https://cdn.auth0.com/website/sdks/logos/auth0_light_mode.png\" width=\"150\"\u003e\n    \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"https://cdn.auth0.com/website/sdks/logos/auth0_dark_mode.png\" width=\"150\"\u003e\n    \u003cimg alt=\"Auth0 Logo\" src=\"https://cdn.auth0.com/website/sdks/logos/auth0_light_mode.png\" width=\"150\"\u003e\n  \u003c/picture\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003eAuth0 is an easy to implement, adaptable authentication and authorization platform. To learn more checkout \u003ca href=\"https://auth0.com/why-auth0\"\u003eWhy Auth0?\u003c/a\u003e\u003c/p\u003e\n\u003cp align=\"center\"\u003e\nThis project is licensed under the MIT license. See the \u003ca href=\"https://github.com/auth0/lock.android/blob/main/LICENSE.md\"\u003e LICENSE\u003c/a\u003e file for more info.\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fauth0%2Flock.android","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fauth0%2Flock.android","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fauth0%2Flock.android/lists"}