none
Using swagger generated client stubs for java RRS feed

  • Question

  • I will need to be able to invoke R based services from java, and have used swagger codegen to generate java client classes for the sample "mtservice" web service that I have started from Visual Studio.  I am running a "one-box" configuration, and am able to invoke the service from R after logging in with user admin and the password I have set for that user.  Just as a first step I would like to do the same from a java client.  I have used the "login" request as follows and received an access token in return, but I am baffled about how to use it.

    ApiClient apiClient = new ApiClient();

    apiClient.setBasePath("http://localhost:12800");
    LoginRequest loginRequest = new LoginRequest();
    loginRequest.setUsername("admin");
    loginRequest.setPassword("*********");
    UserApi userApi= new UserApi(apiClient);
    AccessTokenResponse accessTokenResponse = userApi.login(loginRequest);
    System.out.println(accessTokenResponse.getAccessToken());
    String accessToken = accessTokenResponse.getAccessToken();
    apiClient.setAccessToken(accessToken);

    This throws an exception "No OAuth2 authentication configured. "

    Can anybody give me a hint as to how to proceed from here?

    Monday, June 26, 2017 8:57 PM