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(
  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);

With your consent, we will analyze your behaviour on the website to improve the website for all users. If you consent to the transmission of analysis data, click “Accept”. You can use the website without giving consent to analyze your behaviour. For further information, visit the privacy policy.