Skip to content

Releases: auth0/Guardian.Android

0.8.0

15 Mar 15:10
ac37e29
Compare
Choose a tag to compare

0.8.0 (2024-03-15)

Full Changelog

Changed

  • Add telemetry to track usage

0.7.0

01 Nov 14:54
fcedd17
Compare
Choose a tag to compare

0.7.0 (2023-11-01)

Full Changelog

Changed

  • Add support for transaction linking id
  • Add support for custom domain

0.6.0

01 Jun 11:59
d6ade12
Compare
Choose a tag to compare
  • Use JWT instead of device token #95
  • AndroidX migration for the sample app #94
  • device token method deprecation #96

0.3.0

02 Jun 02:46
Compare
Choose a tag to compare

Full Changelog

Added

0.2.0

07 Dec 21:19
Compare
Choose a tag to compare

Full Changelog

Added

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

0.1.0

23 Nov 19:52
4c534de
Compare
Choose a tag to compare

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