Although not as secure as LoginByToken, you can specify username and password credentials to establish a session with vCenter Server. Follow these steps:
Procedure
- Connect to the vSphere Web service, for example with SSL.
- 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.
- Log in to the server using appropriate credentials (user account, password, and optionally locale).
- Access server-side objects to retrieve data and perform management operations.
- Close the connection.
Example
For sample Java code, see topics in Getting Started with vSphere APIs.