Android Library to authenticate using Auth0 and with a Native Look & Feel
MIT License
Bot releases are visible (Hide)
Published by joshcanhelp over 5 years ago
Changed
Published by hzalaz almost 8 years ago
Published by hzalaz almost 8 years ago
Added
Changed
Deprecated
Fixed
Breaking changes
Published by hzalaz almost 8 years ago
Published by hzalaz almost 8 years ago
Published by hzalaz almost 8 years ago
Added
Fixed
Breaking changes
Since Google will be blocking webview OAuth request we switched the default authentication flow for all social connections from WebView to Browser.
Browser authentication requires a little more configuration in your AndroidManifest.xml
file.
First make sure LockActivity
has singleTask
in android:launchMode
and then add to it an intent-filter
:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="{YOUR_AUTH0_DOMAIN}"
android:pathPrefix="/android/{YOUR_APP_PACKAGE_NAME}/callback"
android:scheme="https" />
</intent-filter>
Published by hzalaz about 8 years ago
Changed
Fixed
Breaking changes
Published by hzalaz about 8 years ago
Published by hzalaz about 8 years ago
Closed issues
Fixed
Added
Changed
Breaking changes
Lock
& PassworlessLock
no longer has the method onCreate(Activity)
and it's logic is now part of the method Lock.Builder.build(Activity)
. So to create a Lock instance you will have
Lock lock = Lock.newBuilder(auth0, callback)
//Customize Lock
.build(this);
Also now you can create Lock
by reading your Auth0 account credentials from a strings file
Lock lock = Lock.newBuilder(callback)
//Customize Lock
.build(this);
and he string file should have
<resources>
<string name="com_auth0_client_id">{CLIENT_ID}</string>
<string name="com_auth0_domain">{DOMAIN}</string>
</resources>
Lock.Builder
no longers allow to customize Lock's theme using the method withTheme(Theme)
since using Android themes is preferable.
Also for all non-database authentication will use Proof Key for Code Exchange by default so your client type in Auth0 dashboard must be Native
.
Published by hzalaz about 8 years ago
Added
Changed
Fixed
Breaking changes
Lock Builder
method
public Builder allowSignIn(boolean allow) {...}
was renamed to
public Builder allowLogIn(boolean allow) {...}
Also this method (and feature) is no longer supported in Lock
public Builder fullscreen(boolean fullscreen) {...}
Published by hzalaz about 8 years ago
Merged pull requests:
Published by hzalaz over 8 years ago
Published by hzalaz over 8 years ago
Merged pull requests:
Published by hzalaz over 8 years ago
Merged pull requests:
Published by hzalaz over 8 years ago
Changed
allow****
and initialScreen
options #286 (lbalmaceda)Breaking changes
AuthenticationCallback
no longer returns UserProfile
, it only returns Credentials
object with the tokens of the authenticated user:
private LockCallback callback = new AuthenticationCallback() {
@Override
public void onAuthentication(Credentials credentials) {
//Authenticated
}
@Override
public void onCanceled() {
//User pressed back
}
@Override
public void onError(LockException error)
//Exception occurred
}
};
To request the UserProfile
, just use AuthenticationAPIClient
from auth0-java
@Override
public void onAuthentication(Credentials credentials) {
AuthenticationAPIClient client = new AuthenticationAPIClient(new Auth0("YOUR_CLIENT_ID", "YOUR_DOMAIN"));
client.tokenInfo(credentials.idToken)
.start(new BaseCallback<UserProfile>() {
@Override
public void onSuccess(UserProfile payload) { }
@Override
public void onFailure(Auth0Exception error) { }
});
}
Published by hzalaz over 8 years ago
First beta release of Lock for Android v2
Now Lock for Android requires these permisssions
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
and this is how LockActivity
should be declared in your Android Manifest
<activity
android:name="com.auth0.android.lock.LockActivity"
android:label="@string/app_name"
android:launchMode="singleTask"
android:screenOrientation="portrait"
android:theme="@style/Lock.Theme">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="YOUR_AUTH0_DOMAIN"
android:pathPrefix="/android/YOUR_APP_PACKAGE_NAME/callback"
android:scheme="https" />
</intent-filter>
</activity>
In the previous version of Lock, you were asked to create a custom Application
class and initialize the Lock.Context
there. Now this is no longer needed. To create a new Lock
instance and configure it, use the Lock.Builder
class.
Create an Auth0
instance to hold your account details, which are the AUTH0_CLIENT_ID
and the AUTH0_DOMAIN
.
Auth0 auth0 = new Auth0("YOUR_AUTH0_CLIENT_ID", "YOUR_AUTH0_DOMAIN");
You'll also need a LockCallback
implementation, we provide AuthenticationCallback
that reports the following events:
If you need a more fine grained control you can implement
LockCallback
full interface.
private LockCallback callback = new AuthenticationCallback() {
@Override
public void onAuthentication(Authentication authentication) {
//Authenticated
}
@Override
public void onCanceled() {
//User pressed back
}
@Override
public void onError(LockException error)
//Exception occurred
}
};
Call the static method Lock.newBuilder(Auth0, AuthenticationCallback)
passing the account details and the callback implementation, and start configuring the Options. After you're done, build the Lock
instance and use it to start the LockActivity
.
This is how your activity should look like.
public class MainActivity extends Activity {
private Lock lock;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
Auth0 auth0 = new Auth0(AUTH0_CLIENT_ID, AUTH0_DOMAIN);
lock = Lock.newBuilder(auth0, callback)
// ... Options
.build();
lock.onCreate(this);
}
@Override
public void onDestroy() {
lock.onDestroy(this);
super.onDestroy();
}
private void performLogin(boolean useBrowser) {
startActivity(lock.newIntent(this));
}
private LockCallback callback = new AuthenticationCallback() {
@Override
public void onAuthentication(Authentication authentication) {
//Authenticated
}
@Override
public void onCanceled() {
//User pressed back
}
@Override
public void onError(LockException error) {
//Exception occurred
}
};
}
Remember to notify the
LockActivity
on everyOnCreate
andOnDestroy
call on your Activity, as it helps to keep the Lock state.
As in the previous version, Lock
can be configured with extra options. Check below if the behavior changed or if they only got renamed.
useBrowser
. Whether to use the WebView or the Browser to request calls to the /authorize
endpoint. Using the Browser has some restrictions.withUsernameStyle
. Defines if it should ask for email only, username only, or both of them. By default, it'll respect the Dashboard configuration of the parameter requires_username
.closable
. Defines if the LockActivity can be closed. By default, it's not closable.fullscreen
. Defines if the LockActivity it's displayed in fullscreen. By default, it's not fullscreen.loginAfterSignUp
. Whether after a SignUp the user should be logged in automatically.allowSignUp
. Shows the Sign Up form if a Database connection is configured.allowForgotPassword
. Shows a link to the Forgot Password form if a Database connection is configured and it's allowed from the Dashboard.setDefaultDatabaseConnection
. Defines which will be the default Database connection. This is useful if your application has many Database connections configured.onlyUseConnections
. Filters the allowed connections from the list configured in the Dashboard..withAuthenticationParameters
. Defines extra authentication parameters, sent on sign up and log in/sign in.initialScreen(int)
allows to customize which form will show first when launching Lock. The possibles values are LOG_IN, SIGN_UP, and FORGOT_PASSWORD. By default LOG_IN is the initial screen.allowLogIn(boolean)
shows the Log In form if a Database connection is configured. By default, this screen it's enabled.allowSignUp(boolean)
shows the Sign Up form if a Database connection is configured. By default, this screen it's enabled.allowForgotPassword(boolean)
shows the Forgot Password form if a Database connection is configured. By default, this screen it's enabled.withSignUpFields(List<CustomFields>)
shows a second screen with extra fields after completing the sign up fields.withProviderResolver(AuthProviderResolver)
pass your own AuthProviderResolver instance to query for AuthProviders.withSocialButtonStyle(int)
allows to customize the Style of the Social buttons. Possible values are SMALL and BIG. If this is not specified, it will default to SMALL when many Social and Db/Enterprise connections are configured; and BIG on the rest of the cases.usePKCE(boolean)
whether to use the new PKCE flow or the old Token exchange one when authenticating. By default, it won't use PKCE.Published by hzalaz over 8 years ago
Closed issues:
Merged pull requests: