Lock Android v1 Customize Your UI


This document covers an outdated version of Lock for Android. We recommend you to upgrade to v2

We are going to use the library EventBus in order to post authentication related events like authentication done and Authentication failed

Add the following dependencies to your project:

Create a new resource file named auth0.xml under values and add the following content, replacing the values with your Auth0 ClientId and Domain

Create two classes AuthenticationEvent and ErrorEvent that will represent a successful authentication or a failed one

Then in your Login Activity add the following fields

In the same Activity onCreate method add the following lines to initialize Auth0 and the fields we added earlier

When you need to login your user with email/password credentials, just paste the following code

For more details about the parameters you can check this wiki page.

Finally handle both AuthenticationEvent and ErrorEvent

Social Authentication

This feature relies on a deprecated grant type. Applications created after June 8th 2017 won't be able to use this feature. We recommend using browser-based flows, as explained in Authentication via Universal Login.

Include the following libraries in your build.gradle:

In your auth0.xml file add the following entry

Configure your Login Activity adding the following intent filters in your AndroidManifest.xml file

Create a new class that implements IdentityProviderCallback, that will handle social authentication (via native integration or using web browser) and post a new event either on success or failure

In your Login Activity add the following fields

And implement the following methods

In the method onCreate initialize Auth0 web provider and store it in a field

Configure Facebook Native integration

You need to configure your Android app for Facebook

Configure Google+ Native integrationApplication class)

Before using Google+, you need to register your Application with Google as explained in this guide

To trigger Facebook authentication just add the following code:

To trigger Google+ authentication just add the following code:

To trigger authentication with any IdP without native integration just add the following code: