hermannpencole / nifi-swagger-client

Client swagger for nifi with security
Apache License 2.0
38 stars 20 forks source link

[Question] How to acces without authentification (username+password)? #5

Closed externus closed 6 years ago

externus commented 6 years ago

Hi, sorry this is less an issue as an question about how to use. My nifi has no authentification at the moment because I have not understood how to apply it. My Question is now, how can I acces with your client when I dont have an authentification (username+password)? The nifi-config tool is working without a authentification so it should be also possible with this client or not?

I would be also happy about a noob friendly explanation how to apply Authentification in nifi :D

Thx

hermannpencole commented 6 years ago

Just do not create token

import com.github.herma
nnpencole.nifi.swagger.*;
import com.github.hermannpencole.nifi.swagger.auth.*;
import com.github.hermannpencole.nifi.swagger.client.model.*;
import com.github.hermannpencole.nifi.swagger.client.AccessApi;

import java.io.File;
import java.util.*;

public class AccessExample {
    public static void main(String[] args) {
        ApiClient client = new ApiClient().setBasePath("http://mynifi/nifi-api");
        Configuration.setDefaultApiClient(client);      
    }
}

And after

ApiClient defaultClient = Configuration.getDefaultApiClient();
FlowApi apiInstance = new FlowApi();
try {
    TemplatesEntity result = apiInstance.getTemplates();
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling FlowApi#getTemplates");
    e.printStackTrace();
}