0.4.0 (2019-04-05)
This release improves the compatibility with Firebase Cloud Messaging (FCM) which has replaced Google Cloud Messaging (GCM) and should no longer been used as April 11. More information on the Firebase blog https://firebase.googleblog.com/2018/04/time-to-upgrade-from-gcm-to-fcm.html
Added
- Allow to parse notifications from a Map instance #84 (lbalmaceda)
Changed
- Migrate sample from GCM to FCM #87 (lbalmaceda)
- Update gradle and dependencies version #82 (lbalmaceda)
Deprecated
- Deprecate methods to parse a notification payload from a Bundle #85 (lbalmaceda)
0.3.0 (2017-06-01)
Added
0.2.0 (2016-12-07)
Added
0.1.0 (2016-11-23)
First release of Guardian for Android
Add these lines to your build.gradle
dependencies file:
compile 'com.auth0.android:guardian:0.1.0'
Create an instance of Guardian
:
String domain = "<TENANT>.guardian.auth0.com";
Guardian guardian = new Guardian.Builder()
.domain(domain)
.build();
To create an enroll, create a pair of RSA keys, obtain the Guardian enrollment data from a Guardian QR code and use it like this:
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA");
keyPairGenerator.initialize(2048); // you MUST use at least 2048 bit keys
KeyPair keyPair = keyPairGenerator.generateKeyPair();
CurrentDevice device = new CurrentDevice(context, "gcmToken", "deviceName");
String enrollmentUriFromQr = ...; // the data from a Guardian QR code
guardian
.enroll(enrollmentUriFromQr, device, keyPair)
.start(new Callback<Enrollment> {
@Override
void onSuccess(Enrollment enrollment) {
// we have the enrollment data
}
@Override
void onFailure(Throwable exception) {
// something failed
}
});
To allow or reject a login request you first need to get the Guardian Notification
:
// at the GCM listener you receive a Bundle
@Override
public void onMessageReceived(String from, Bundle data) {
Notification notification = Guardian.parseNotification(data);
if (notification != null) {
handleGuardianNotification(notification);
return;
}
/* Handle other push notifications you might be using ... */
}
Then, to allow the login request:
guardian
.allow(notification, enrollment)
.execute(); // or start(new Callback<> ...) asynchronously