javaibm-cloudobject-storageopenstack4j

Authenticating to IBM Object Storage with OpenStack4j


I'm having a hard time authenticating to the Object Storage Service in IBM Cloud from an external Java application using the OpenStack4j library (version 3.1.0). Here's how I'm trying:

Identifier domainIdentifier = Identifier.byName("DOMAIN");
Identifier projectIdentifier= Identifier.byName("PROJECT");

OSClient.OSClientV3 os = OSFactory.builderV3()
  .endpoint("https://identity.open.softlayer.com/v3")
  .credentials("USER", "PASS")
  .scopeToProject(projectIdentifier, domainIdentifier)
  .authenticate();

References:

https://github.com/acloudfan/IBM-Object-Storage-Sample/

https://github.com/ibm-bluemix-mobile-services/bluemix-objectstorage-sample-liberty

The problem seems to be that I can't figure out where to get the DOMAIN and PROJECT information mentioned above, and perhaps the endpoint. The documentation says to obtain them from the Object Storage page under Service Credentials and View Credentials. I do see a JSON output with the following fields:

{
  "apikey": "...",
  "endpoints": "...",
  "iam_apikey_description": "...",
  "iam_apikey_name": "...",
  "iam_role_crn": "...",
  "iam_serviceid_crn": "...",
  "resource_instance_id": "..."
}

None of which seem to relate to domain or project information, at least by name. I even created a separate Web App with an Object Storage Connector, and tried to obtain the information from the Environment Variables page, as some of the documentation suggested, but with no luck.

What I ultimately want to achieve is to be able to ingest files to a container I created, and use the data & analytics services on top (Data Science Experience).


Solution

  • The reason for the confusion is that there are (or used to be) two different Object Storage services on Bluemix (Object Storage and Cloud Object Storage). The bluemix-mobile-services SDK is written for the Object Storage one rather than the service you have provisioned.

    The App Service page has a starter kit which makes it pretty easy to get starter code and set up with a toolchain for a Liberty project:

    example of starter

    This has the domain field for the credentials. (Here is a link to the starter kits & I added the Object Storage service which injects the credentials: https://console.bluemix.net/developer/appservice/starter-kits. Or you can create a project with just the service and no code: https://console.bluemix.net/developer/appservice/create-project?services=Object-Storage)

    Here is the documentation for the Java SDK for Cloud Object Storage if you would like to use that service instead:

    https://console.bluemix.net/docs/services/cloud-object-storage/libraries/java.html#java


    Here is a comparison of the Object Storage services:

    https://console.bluemix.net/catalog/infrastructure/object-storage-group