You can use REST API SDK with a configured vRA authentication in a multi-tenant or a single-tenant environment.

To obtain an authentication token (Oauth2.0) required for the code below, see the vRO REST API authorization using Oauth2.0 Authentication (2148518) KB article.

Note: Obtain a Session in vRealize Automation Authentication Mode

The following example code obtains a session in vRealize Automation Authentication mode in both a single tenant and a multi-tenant environment.

  • If multi-tenancy is not enabled:
    URI uri = URI.create("https://orchestrator-server:8283/vco/api");
    VcoSessionFactory sessionFactory = new DefaultVcoSessionFactory(uri);
    String token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJqdGkiOiJjNzg4NWNiYS1hZTFmLTRiM2UtYmYyYi04ZmRmNzY3N"
    + "GZiZWEiLCJwcm4iOiJhZG1pbmlzdHJhdG9yQFZTUEhFUkUuTE9DQUwiLCJkb21haW4iOiJ2c3BoZXJlLmxvY2FsIiwidXNlcl9pZCI6Ij"
    + "MiLCJhdXRoX3RpbWUiOjE1MDIyMDIxMTAsImlzcyI6Imh0dHBzOi8vc2YtMjktMTAtMjkuc29mLW1idS5lbmcudm13YXJlLmN"
    + "vbS9TQUFTL3QvdnNwaGVyZS5sb2NhbC9hdXRoIiwiYXVkIjoiaHR0cHM6Ly9zZi0yOS0xMC0yOS5zb2YtbWJ1LmVuZy52bXdhcmUuY29tL"
    + "1NBQVMvdC92c3BoZXJlLmxvY2FsL2F1dGgvb2F1dGh0b2tlbiIsImN0eCI6Ilt7XCJtdGRcIjpcInVybjpvYXNpczpuYW1lczp"
    + "0YzpTQU1MOjIuMDphYzpjbGFzc2VzOlBhc3N3b3JkUHJvdGVjdGVkVHJhbnNwb3J0XCIsXCJpYXRcIjoxNTAyMjAyMTEwLFwiaWRcIjoxM"
    + "n1dIiwic2NwIjoidXNlciIsImlkcCI6IjAiLCJlbWwiOiJhZG1pbmlzdHJhdG9yQHNmLTI5LTEwLTI5LnNvZi1tYnUuZW5nLnZ"
    + "td2FyZS5jb20iLCJjaWQiOiJjYWZlX2NsaS1yRlJlNEx6bURnIiwiZGlkIjoiIiwid2lkIjoiIiwiZXhwIjoxNTAyMjMwOTEwLCJpYXQiOj"
    + "E1MDIyMDIxMTAsInN1YiI6IjQ1ZjQwNWUzLTNlNTgtNGJmZC1hNzMwLTQ1MjU4OWIxOGUxNyIsInBybl90eXBlIjoiVVNFUiJ9."
    + "G9gEQPtmEH5jYab-IlTK8NFYcwc3JZCEEjsmpUSH6oxLmZKEf-1JbsysBVH4ufqmGah3GMvmy6PUiTTamLRLFkCLwa50OQCQ-qgKutZl21R"
    + "m740qBKLhmBB0NQg19ysMAVJNSxapFzirmWurF_5CKpv4WM7Y8H_bY9iNmDKQTXI";
    
    //provide OAuth2 token obtained in step 1 here
    Authentication auth = new OAuthTokenAuthentication(token);
    
    VcoSession session = sessionFactory.newSession(auth);
    //Use the session here
  • If multi-tenancy is enabled:
    • For users from regular tenants:
      URI uri = URI.create("https://orchestrator-server:8283/vco/api");
      VcoSessionFactory sessionFactory = new DefaultVcoSessionFactory(uri);
      String token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJqdGkiOiJjNzg4NWNiYS1hZTFmLTRiM2UtYmYyYi04ZmRmNzY3N"
      + "GZiZWEiLCJwcm4iOiJhZG1pbmlzdHJhdG9yQFZTUEhFUkUuTE9DQUwiLCJkb21haW4iOiJ2c3BoZXJlLmxvY2FsIiwidXNlcl9pZCI6Ij"
      + "MiLCJhdXRoX3RpbWUiOjE1MDIyMDIxMTAsImlzcyI6Imh0dHBzOi8vc2YtMjktMTAtMjkuc29mLW1idS5lbmcudm13YXJlLmN"
      + "vbS9TQUFTL3QvdnNwaGVyZS5sb2NhbC9hdXRoIiwiYXVkIjoiaHR0cHM6Ly9zZi0yOS0xMC0yOS5zb2YtbWJ1LmVuZy52bXdhcmUuY29tL"
      + "1NBQVMvdC92c3BoZXJlLmxvY2FsL2F1dGgvb2F1dGh0b2tlbiIsImN0eCI6Ilt7XCJtdGRcIjpcInVybjpvYXNpczpuYW1lczp"
      + "0YzpTQU1MOjIuMDphYzpjbGFzc2VzOlBhc3N3b3JkUHJvdGVjdGVkVHJhbnNwb3J0XCIsXCJpYXRcIjoxNTAyMjAyMTEwLFwiaWRcIjoxM"
      + "n1dIiwic2NwIjoidXNlciIsImlkcCI6IjAiLCJlbWwiOiJhZG1pbmlzdHJhdG9yQHNmLTI5LTEwLTI5LnNvZi1tYnUuZW5nLnZ"
      + "td2FyZS5jb20iLCJjaWQiOiJjYWZlX2NsaS1yRlJlNEx6bURnIiwiZGlkIjoiIiwid2lkIjoiIiwiZXhwIjoxNTAyMjMwOTEwLCJpYXQiOj"
      + "E1MDIyMDIxMTAsInN1YiI6IjQ1ZjQwNWUzLTNlNTgtNGJmZC1hNzMwLTQ1MjU4OWIxOGUxNyIsInBybl90eXBlIjoiVVNFUiJ9."
      + "G9gEQPtmEH5jYab-IlTK8NFYcwc3JZCEEjsmpUSH6oxLmZKEf-1JbsysBVH4ufqmGah3GMvmy6PUiTTamLRLFkCLwa50OQCQ-qgKutZl21R"
      + "m740qBKLhmBB0NQg19ysMAVJNSxapFzirmWurF_5CKpv4WM7Y8H_bY9iNmDKQTXI";
      
      //provide OAuth2 token obtained in step 1 here
      Authentication auth = new OAuthTokenAuthentication(token);
      
      VcoSession session = sessionFactory.newSession(auth);
      //The operations will be executed in the scope of the tenant authenticated with the token above.
      
      //Use the session below
      
    • For solution users:

      Solution users can work in their own tenant scope and in the scope of regular tenants. They can override the scope of the operations they perform.

      URI uri = URI.create("https://orchestrator-server:8283/vco/api");
      VcoSessionFactory sessionFactory = new DefaultVcoSessionFactory(uri);
      
      exapmle
      
      String token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJqdGkiOiJjNzg4NWNiYS1hZTFmLTRiM2UtYmYyYi04ZmRmNzY3N"
      + "GZiZWEiLCJwcm4iOiJhZG1pbmlzdHJhdG9yQFZTUEhFUkUuTE9DQUwiLCJkb21haW4iOiJ2c3BoZXJlLmxvY2FsIiwidXNlcl9pZCI6Ij"
      + "MiLCJhdXRoX3RpbWUiOjE1MDIyMDIxMTAsImlzcyI6Imh0dHBzOi8vc2YtMjktMTAtMjkuc29mLW1idS5lbmcudm13YXJlLmN"
      + "vbS9TQUFTL3QvdnNwaGVyZS5sb2NhbC9hdXRoIiwiYXVkIjoiaHR0cHM6Ly9zZi0yOS0xMC0yOS5zb2YtbWJ1LmVuZy52bXdhcmUuY29tL"
      + "1NBQVMvdC92c3BoZXJlLmxvY2FsL2F1dGgvb2F1dGh0b2tlbiIsImN0eCI6Ilt7XCJtdGRcIjpcInVybjpvYXNpczpuYW1lczp"
      + "0YzpTQU1MOjIuMDphYzpjbGFzc2VzOlBhc3N3b3JkUHJvdGVjdGVkVHJhbnNwb3J0XCIsXCJpYXRcIjoxNTAyMjAyMTEwLFwiaWRcIjoxM"
      + "n1dIiwic2NwIjoidXNlciIsImlkcCI6IjAiLCJlbWwiOiJhZG1pbmlzdHJhdG9yQHNmLTI5LTEwLTI5LnNvZi1tYnUuZW5nLnZ"
      + "td2FyZS5jb20iLCJjaWQiOiJjYWZlX2NsaS1yRlJlNEx6bURnIiwiZGlkIjoiIiwid2lkIjoiIiwiZXhwIjoxNTAyMjMwOTEwLCJpYXQiOj"
      + "E1MDIyMDIxMTAsInN1YiI6IjQ1ZjQwNWUzLTNlNTgtNGJmZC1hNzMwLTQ1MjU4OWIxOGUxNyIsInBybl90eXBlIjoiVVNFUiJ9."
      + "G9gEQPtmEH5jYab-IlTK8NFYcwc3JZCEEjsmpUSH6oxLmZKEf-1JbsysBVH4ufqmGah3GMvmy6PUiTTamLRLFkCLwa50OQCQ-qgKutZl21R"
      + "m740qBKLhmBB0NQg19ysMAVJNSxapFzirmWurF_5CKpv4WM7Y8H_bY9iNmDKQTXI";
      
      //provide OAuth2 token obtained in step 1 here
      Authentication auth = new OAuthTokenAuthentication(token);
      
      
      // By default each tenant works in its tenant scope. However, solution users can overrde the tenant in which they performa a given operation:
      // Here, users of SDK should provide a value that is meanningful to their context.
      String overrideWithTenant = "nonSolutionUserTenant";
      
      
      VcoSession session = sessionFactory.newSession(auth, overrideWithTenant);
      
      //Use session below