Hello,
I am trying to use the Java API client against a hosted V1 instance.
The 'GettingStarted' example code linked from readme.md uses an EnvironmentContext to set everything up. This appears to depend on editing the APIConfiguration.properties file in the api client jar. I do not want to do this; my integration needs to accept the username and password at runtime.
I'm creating instances of V1APIConnector with the appropriate URL, username and password, then passing those into the constructors for MetaModel and Services. Later I try to pass a Query to Services.retrieve(). As soon as I do, I get a SecurityException() from V1APIConnector.getData().
I inspected the traffic at this point and it looks like the credentials are not being processed for some reason. The initial connection attempt has no authentication header, and after the 401 error is returned by the server there is no followup - the SecurityException() is generated instead. When I catch the exception and print out the user/pass, they are correct; if I test the same URLs and credentials in a browser they work fine.
The Authenticator/Credentials stuff in V1APIConnector.java looks like it should work based on the docs (http://docs.oracle.com/javase/6/docs/technotes/guides/net/http-auth.html), so I am not sure why this is happening.
I am going to try rolling my own basic auth header and sticking it in V1APIConnector.customHttpHeaders, but I don't think this is the right way to use the SDK. What am I doing wrong?
Thanks,
-Will
I figured this out as soon as I sent the mail. It was a dumb error – checking if username was null vs. not null incorrectly. I was never sending credentials if they were present.
Sorry for the list noise.
-Will