Name: Lock-SmartLock
Owner: Auth0
Description: Google Smart Lock support for Auth0 Lock
Created: 2015-05-30 15:47:38.0
Updated: 2018-02-04 05:43:55.0
Pushed: 2016-04-12 11:49:41.0
Homepage: https://auth0.com/lock
Size: 117
Language: Java
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Auth0 is an authentication broker that supports social identity providers as well as enterprise identity providers such as Active Directory, LDAP, Google Apps and Salesforce.
Auth0 Lock integration with Google Smart Lock for Android
Android API level 14+ and Google Play Services 7.5.+
Lock + SmartLock is available both in Maven Central and JCenter. To start using it add this line to your build.gradle
dependencies file:
ile 'com.auth0.android:lock-smartlock:0.1.+'
Next we're going to configure Auth0 Lock & Google's Smart Lock
Once it's installed, you'll need to configure LockActivity in yourAndroidManifest.xml
, inside the application
tag:
Auth0 Lock-->
ivity
droid:name="com.auth0.lock.LockActivity"
droid:theme="@style/Lock.Theme"
droid:screenOrientation="portrait"
droid:launchMode="singleTask">
ntent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="a0INSERT_YOUR_APP_CLIENT_ID" android:host="@string/auth0_domain"/>
intent-filter>
tivity>
a-data android:name="com.auth0.lock.client-id" android:value="@string/auth0_client_id"/>
a-data android:name="com.auth0.lock.domain-url" android:value="@string/auth0_domain"/>
Auth0 Lock End-->
The value
@string/auth0_client_id
is your application's clientID and@string/auth0_domain
is your tenant's domain in Auth0, both values can be found in your app's settings. The final value ofandroid:scheme
must be in lowercase
Also you'll need to add the following permission:
s-permission android:name="android.permission.INTERNET"/>
Finally, Make your Application class implement the interface com.auth0.lock.LockProvider
and create a SmartLock
instance:
ic class MyApplication extends Application implements LockProvider {
private SmartLock lock;
public void onCreate() {
super.onCreate();
lock = new SmartLock.Builder(this)
.loadFromApplication(this)
/** Other configuration goes here */
.closable(true)
.build();
}
@Override
public Lock getLock() {
return lock;
}
For more information about configuration options for Lock, please go to Lock repo
To enable your application to access Smart Lock, you need to register your application in Google Developers Console by creating a project and registering your keystore SHA1 fingerprint.
We recoomend following Google's Getting Started Guide
Once you have registered your app just add this to your android manifest:
a-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />
From any Activity just override the following methods that will allow Lock
to interact with Smart Lock
rride
ected void onStart() {
super.onStart();
SmartLock.getSmartLock(this).onStart();
rride
ected void onStop() {
super.onStop();
SmartLock.getSmartLock(this).onStop();
rride
ected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
SmartLock.getSmartLock(this).onActivityResult(this, requestCode, resultCode, data);
Then register the following BroadcastReceiver
to be notified when the user is authenticated
ate BroadcastReceiver authenticationReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
UserProfile profile = intent.getParcelableExtra("profile");
Token token = intent.getParcelableExtra("token");
// Handle user's credentials
}
rride
ected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//.....
broadcastManager = LocalBroadcastManager.getInstance(this);
broadcastManager.registerReceiver(authenticationReceiver, new IntentFilter(Lock.AUTHENTICATION_ACTION));
rride
ected void onDestroy() {
super.onDestroy();
broadcastManager.unregisterReceiver(authenticationReceiver);
And to login, just call this method
tLock.getSmartLock(this).loginFromActivity(this);
If you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. The Responsible Disclosure Program details the procedure for disclosing security issues.
Auth0 helps you to:
Lock is available under the MIT license. See the LICENSE file for more info.