I’m using vROps Java Client Bindings to create Java client capable of consuming vROps REST API.
My source code to create the client:
Client client = ClientConfig.builder()
ApplicationVersion version = client.apiVersionsClient().getCurrentVersion();
It works with basicAuth, which uses vROps user credentials.
I would like to switch to vcTokenAuth method, which is very briefly described under /suite-api/docs/java/com/vmware/ops/api/client/Client.ClientConfig.Builder.html#vcTokenAuth(java.lang.String)
Token is acquired with vimPortType.acquireCloneTicket() method from Web Services SDK.
Simply switching to .vcTokenAuth instead of .basicAuth doesn’t work. For token I’m using cloneTicket acquired from vCenter Server.
It generates following warning message and stack trace:
478 [main] WARN org.springframework.web.client.RestTemplate - GET request for "https://10.172.181.231/suite-api/api/versions/current?_no_links=true" resulted in 500 (Internal Server Error); invoking error handler
Exception in thread "main" com.vmware.ops.api.client.exceptions.ServerException: Internal Server error, cause unknown.
at com.sun.proxy.$Proxy40.getCurrentVersion(Unknown Source)
My question is what are the steps to successfully use vcTokenAuth mechanism? Are there any prerequisites that need to be fulfilled before using it? Where do I get the token from, because I’m not entirely sure I’m getting the correct one? The documentation isn’t very precise about that.
Were you able to instantiate the client with the code sample they provided in the documentation?
If so, what am I missing here? I have added the jar file for the client api to my library, then I create the client class right? Or do I instantiate the client inside the body of the code for whatever program I am trying to run? Netbeans seemed to have a fit when I tried to paste that client = client code into the body of my program.
If you have any insight into this process please let me know. I'm new to coding with Java but think I have a pretty decent understanding of object oriented programming.