Error Invalid credentials when using bootstrap user

Java Microservice on Cumulocity 10.17

I’m trying to make my java microservice dynamic and supports multi-tenancy, and therefore would like to get all tenants subscribed to the application and their service username/passwords.

In order to do that, I’m using for authentication the bootstrap username and password provided by the Autowired Environment. I’m doing a GET call to the endpoint: /application/currentApplication/subscriptions.

For that I’m also using the baseurl provided by the environment for the domain, for the request to look like this: GET http://cumulocity:8111/application/currentApplication/subscriptions HTTP/1.1.

I made sure that the username and password are the bootstrap correct credentials, and made sure when making the call from postman using the real tenant domain, I would get the needed response. But when hosting the microservice, when the http request is executed, I get back the 401 error: “error”:“security/Unauthorized”,“message”:“Invalid credentials!”. I tried doing the authentication using the credentials provider, and using the base64 header, but both ways returned the same error.

Could someone help me with what am I doing wrong here?

My suspicion is that you’re missing to specify the Tenant ID in the username. To be sure, try making the request with User {C8Y_BOOTSTRAP_TENANT}/{C8Y_BOOTSTRAP_USER}.

As you are using Java and probably the SDK, you could also take a look at MicroserviceSubscriptionsService. Below snippet should output all your services subscriptions:

public class OmarsService {
    MicroserviceSubscriptionsService subscriptionsService;

    public void onSubscriptionsInitialized(MicroserviceSubscriptionsInitializedEvent event) {"Subscriptions initialized.");
        Collection<MicroserviceCredentials> allActiveSubscriptions = subscriptionsService.getAll();
        for(MicroserviceCredentials mc : allActiveSubscriptions){
  "Tenant: " + mc.getTenant());
  "User: " + mc.getUsername());
  "Pass: " + mc.getPassword());
        // execute some runnable on all tenants
        // execute in specific tenant
        subscriptionService.runForTenant("t1234", ...);
1 Like