Although not as secure as LoginByToken, you can specify username and password credentials to establish a session with vCenter Server. Follow these steps:

Procedure

  1. Connect to the vSphere Web service, for example with SSL.
  2. Create a managed object referring to ServiceInstance. Use this object to retrieve object ServiceContent from the server. ServiceContent contains a reference to the root folder for the inventory and references to managed objects that provide vSphere services. Create another object for access to vSphere API methods.
  3. Log in to the server using appropriate credentials (user account, password, and optionally locale).
  4. Access server-side objects to retrieve data and perform management operations.
  5. Close the connection.

Example

For sample Java code, see topics in Getting Started with vSphere APIs.