0

This should be simple but I must be missing something. So there is an authorization url which I need to pass a username and password to:

 OkHttpClient client = new OkHttpClient.Builder()
                    .cookieJar(new CookieJar() {
                        private final HashMap<HttpUrl, List<Cookie>> cookieStore = new HashMap<>();

                        @Override
                        public void saveFromResponse(HttpUrl url, List<Cookie> cookies) {
                            cookieStore.put(url, cookies);
                        }

                        @Override
                        public List<Cookie> loadForRequest(HttpUrl url) {
                            List<Cookie> cookies = cookieStore.get(url);
                            return cookies != null ? cookies : new ArrayList<Cookie>();
                        }
                    })
                    .build();

HttpUrl.Builder urlBuilder = HttpUrl.parse(AUTHTOKEN_URL).newBuilder();
                            urlBuilder.addQueryParameter("username", AUTHTOKEN_USERNAME);
                            urlBuilder.addQueryParameter("password", AUTHTOKEN_PASSWORD);
                            String url = urlBuilder.build().toString();

                            Request request = new Request.Builder()
                                    .url(url)
                                    .build();

                            Response response = client.newCall(request).execute();

When I call AUTHTOKEN_URL the result is "OK" but saveFromResponse never seems to get called, so I'm thinking something is just not right because when I make the next http call to another server that depends on this auth token is does not return any data.

enter image description here

enter image description here

Mike6679
  • 5,547
  • 19
  • 63
  • 108

0 Answers0