Lock Android v2 Custom Authentication Providers
Auth0.Android includes the
WebAuthProvider class to handle the authorize flow using the Browser. But what if you want to use your own implementation or a Native version of an
The AuthProvider class
Create a class that implements the
AuthProvider interface and override its methods.
You can also use any Native implementation already provided by Auth0. The native social authentication providers currently available are Google and Facebook.
The AuthHandler class
Auth0.Android includes an interface for you to implement and define which provider to use given a Strategy and Connection name. It has a single method that returns an
AuthProvider for a given strategy/connection name. If no provider can handle those values, it should return
null. On Lock side, when no provider is returned it will default to
Finally, on the
Lock.Builder class you need to set the AuthHandlers to use on that Lock instance.
This way when Lock needs to authenticate a user with OAuth, it will ask the handlers respecting the given order, which of them can handle a given connection/strategy name. If the first one can handle it, the second won't be called. If no handlers can match the request (Lock received
null), Lock will internally default to use
WebAuthProvider. Also note that
strategy can be null.
Our Google and Facebook native social providers will provide
AuthHandlers for you to use directly with Lock.