Authorization

A content connector can support one of the following authorization models.

  • No Auth
  • OAuth
  • Basic

No Auth

This is used when the content connector does not require any authorization. In this case, the connector picker is launched directly without invoking any authorization screen.

ServerResource Implementation

serverInfo.authenticationType = AuthenticationType.NO_AUTH

OAuth

This is used when a content connector supports OAuth. In this case, OCM ensures that the OAuth flow is invoked to fetch the access token. For subsequent access, the already fetched token is used until it expires.

serverResource Implementation

serverInfo.authenticationType = AuthenticationType.OAUTH

The content connector also needs to define the required custom fields used in the OAuth flow.

ServerResource Implementation

{
    FieldInfo field = new FieldInfo();
 
    field.ID = UnsplashAdapter.FIELD_ID_REFRESH_TOKEN;
    field.label = ResourceBundleUtil.getDefaultLocalizedString("cds.unsplash.adapter.field.refreshtoken.label");
    field.labelLocalizations =
        ResourceBundleUtil.getLocalizedData("cds.unsplash.adapter.field.refreshtoken.label");
    field.datatype = FieldDatatype.STRING;
    field.userSettable = false;
    field.siteSettable = false;
    field.connectorSettable = true;
    field.authorizationURLParameter = false;
 
    serverInfo.fields.add(field);
}
 
{
    FieldInfo field = new FieldInfo();
 
    field.ID = UnsplashAdapter.FIELD_ID_ACCESS_TOKEN;
    field.label = ResourceBundleUtil.getDefaultLocalizedString("cds.unsplash.adapter.field.accesstoken.label");
    field.labelLocalizations =
        ResourceBundleUtil.getLocalizedData("cds.unsplash.adapter.field.accesstoken.label");
    field.datatype = FieldDatatype.STRING;
    field.userSettable = false;
    field.siteSettable = false;
    field.connectorSettable = true;
    field.authorizationURLParameter = false;
 
    serverInfo.fields.add(field);
}
 
{
    FieldInfo field = new FieldInfo();
 
    field.ID = UnsplashAdapter.FIELD_ID_AUTHORIZATION_URL_PARAMETER_CODE;
    field.label = ResourceBundleUtil.getDefaultLocalizedString("cds.unsplash.adapter.field.authurl.code.label");
    field.labelLocalizations =
        ResourceBundleUtil.getLocalizedData("cds.unsplash.adapter.field.authurl.code.label");
    field.datatype = FieldDatatype.STRING;
    field.userSettable = false;
    field.siteSettable = false;
    field.connectorSettable = false;
    field.authorizationURLParameter = true;
 
    serverInfo.fields.add(field);
}
 
{
    FieldInfo field = new FieldInfo();
 
    field.ID = UnsplashAdapter.FIELD_ID_AUTHORIZATION_URL_PARAMETER_ERROR;
    field.label =
        ResourceBundleUtil.getDefaultLocalizedString("cds.unsplash.adapter.field.authurl.error.label");
    field.labelLocalizations =
        ResourceBundleUtil.getLocalizedData("cds.unsplash.adapter.field.authurl.error.label");
    field.datatype = FieldDatatype.STRING;
    field.userSettable = false;
    field.siteSettable = false;
    field.connectorSettable = false;
    field.authorizationURLParameter = true;
 
    serverInfo.fields.add(field);

And also implement the following interfaces documented in the preceding text:

  1. /rest/api/v1/authorization/authorizationURLs

  2. /rest/api/v1/authorization/completedAuthorizations

Basic

This is used when content connector requires login credentials to connect to the back end. Here OCM will prompt you to enter sign-in details before launching the picker for the first time. If the credentials are available, then they will be used.

Note:

Oracle no longer supports Basic authorization for external consumption.
ServerResource Implementation

serverInfo.authenticationType = AuthenticationType.BASIC

You also need to define all the login fields in the server implementation. These fields will display in the login screen.

// custom field for User Name
{
FieldInfo field = new FieldInfo();
field.ID = "UserName";
field.label = ResourceBundleUtil.getDefaultLocalizedString("cds.unsplash.
adapter.field.username.label");
field.labelLocalizations = ResourceBundleUtil.getLocalizedData("
cds.unsplash.adapter.field.username.label");
field.description = ResourceBundleUtil.getDefaultLocalized-
String("cds.unsplash.adapter.field.username.desc");
field.descriptionLocalizations = ResourceBundleUtil.getLocalizedData("
cds.unsplash.adapter.field.username.desc");
field.datatype = FieldDatatype.STRING;
field.userSettable = true;
field.siteSettable = false;
field.connectorSettable = false;
field.authorizationURLParameter = false;
field.required = true;
serverInfo.fields.add(field);
}
// custom field for password
{
FieldInfo field = new FieldInfo();
field.ID = "UserPwd";
field.label = ResourceBundleUtil.getDefaultLocalizedString("cds.unsplash.
adapter.field.password.label");
field.labelLocalizations = ResourceBundleUtil.getLocalizedData("
cds.unsplash.adapter.field.password.label");
field.description = ResourceBundleUtil.getDefaultLocalized-
String("cds.unsplash.adapter.field.password.desc");
field.descriptionLocalizations = ResourceBundleUtil.getLocalizedData("
cds.unsplash.adapter.field.password.desc");
field.datatype = FieldDatatype.PASSWORD;
field.userSettable = true;
field.siteSettable = false;
field.connectorSettable = false;
field.authorizationURLParameter = false;
field.required = true;
serverInfo.fields.add(field);
}

Besides this, the content connector needs to implement the following interface, as described in the preceding text.

/rest/api/v1/authorization/basicAuthorization
Subsequently the user credentials (password base64 encoded) will be passed via headers for other calls, like filesystem and get content.