Basic Authentication with Resteasy client

后端 未结 4 1031
囚心锁ツ
囚心锁ツ 2021-02-20 05:57

I\'m trying to perform an basic auth to the login-module which runs on my jboss using REST. I already found an StackOverflow topic which explains how to authenticate with creden

4条回答
  •  后悔当初
    2021-02-20 07:02

    One can use org.jboss.resteasy.client.jaxrs.BasicAuthentication which is packaged with resteasy-client 3.x and is meant specifically for basic authentication.

    Client client = ClientBuilder.newClient();    
    ResteasyWebTarget resteasyWebTarget = (ResteasyWebTarget)client.target("http://mywebservice/rest/api");
    resteasyWebTarget.register(new BasicAuthentication("username", "passwd"));
    

提交回复
热议问题