JVM Quickstart

Using the data4life JVM SDK

The Java Virtual Machine (JVM) SDK only supports a single-user use case. For every individual user, the SDK must be instantiated with the user alias.

  1. To instantiate the SDK.

    Data4LifeClient client = Data4LifeClient.init(
        userAlias,
        clientId,
        clientSecret,
        environment,
        redirectUrl,
        secureStore,
        authorizationStore
    );
  2. To start the OAuth 2.0 authorization flow.

    // Open the authorization URL in the browser and let the user authorize
    String authorizationUrl = client.getAuthorizationUrl()
  3. To finish the OAuth authorization flow by passing the OAuth callback URL with the code and state back to the SDK.

    String callbackUrl = "https://.../oauth/callback?code=12345&state=abcde"
    boolean authorized = client.finishLogin(callbackUrl)
  4. After the authorization finishes, the application can use the client to upload a document. To create a document with attachments with the client.createRecord method.

    client.createRecord(record, customCreationDate, resultListener)

Extracting the user ID from the OAuth callback URL

To extract the user ID from the callback URL after an OAuth login or registration, the SDK provides the UserIdExtractor class.

UserIdExtractor extractor = new UserIdExtractor();

String userId = extractor.extract(callbackUrl);

This website uses cookies - see our privacy policy for more information about cookies and your rights as a user. Click on "accept" to allow the cookie use.
More about this