Authorization documentation

This section covers the authorization project features of the SDK. Authentication is the process of verifying who a user is, while authorization is the process of verifying what they have access to.

Starting authorization requests

The authorization request is started with the following code sample which launches an Activity to present the login screen to the user for authentication.

Intent authIntent = Data4LifeClient.getInstance().getLoginIntent(MainActivity.this, null);
startActivityForResult(authIntent, requestCode);

You can pass along optional scopes, otherwise the SDK uses the default scopes for the authorization request.

Ending authorization requests

Once the user is logged in, canceled the authorization request, or if an exception occured during the authentication process, the SDK sends the response to the integrator application in the onActivityResult(…) method. The authorization results can be the following:

  • Activity.RESULT_OK – when the login is successful.

  • Activity.RESULT_CANCELED – when the login fails, with additional payload in data, as shown in the example.

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode == GC_AUTH) {
        if (resultCode == RESULT_OK) {
        } else if (data.getExtras() != null) {
            if (data.getExtras().containsKey("error")) {
                Snackbar.make(mRootCL, "Failed to log in to data4life", Snackbar.LENGTH_SHORT).show();
            } else if (data.getExtras().containsKey("canceled")) {
                Snackbar.make(mRootCL, "User canceled authorization request", Snackbar.LENGTH_SHORT).show();

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