Skip to content

Latest commit

 

History

History
103 lines (74 loc) · 3.71 KB

CHANGELOG.md

File metadata and controls

103 lines (74 loc) · 3.71 KB

Change Log

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

Full Changelog

Added

  • Allow to parse notifications from a Map instance #84 (lbalmaceda)

Changed

Deprecated

  • Deprecate methods to parse a notification payload from a Bundle #85 (lbalmaceda)

0.3.0 (2017-06-01)

Full Changelog

Added

0.2.0 (2016-12-07)

Full Changelog

Added

  • Add method to get errorCode and isLoginTransactionNotFound() #62 (nikolaseu)

0.1.0 (2016-11-23)

First release of Guardian for Android

Install

Add these lines to your build.gradle dependencies file:

compile 'com.auth0.android:guardian:0.1.0'

Usage

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