Authentication with javax.ws.rs.client.Client

0

I'm trying to get a get to a service, which requires token authentication. It must be added to the header. The code that performs this action is the following:

try {
            MultivaluedMap<String, Object> head = new MultivaluedHashMap<String, Object>();
            head.add("Gtw-Transaction-Id", this.jobExecutionContext.getGtwTransactionId());
            head.add("Gtw-Sec-User-Token", this.jobExecutionContext.getLoginToken());
            head.add("Content-Type", "application/json");

            response = this.restClient.target(new URI(this.endpoint + resource))
                    .request()
                    .headers(head)
                    .get();

        } catch (Exception ex) {
            response = null;
        }

As you can see, I am adding in the header, the necessary token for authentication. However, the answer is "Missing Authentication Token". The same query I do with Postman and it works.

What can be wrong?

since thank you very much!

    
asked by AdrianGNR 13.12.2018 в 17:42
source

0 answers