code: private void processRedirectResponse(Response response) throws RuntimeException, JSONException, MalformedURLException {
          // a valid redirect response must contain the Location header.
          ResponseImpl responseImpl = (ResponseImpl)response;
          List<String> locationHeaders = responseImpl.getHeader(LOCATION_HEADER_NAME);
  
          String location = (locationHeaders != null && locationHeaders.size() > 0) ? locationHeaders.get(0) : null;
  
          if (location == null) {
              throw new RuntimeException("Redirect response does not contain 'Location' header.");
          }
  
          // the redirect location url should contain "wl_result" value in query parameters.
          URL url = new URL(location);
          String query = url.getQuery();
  
          if (query.contains(WL_RESULT)) {
              String result = Utils.getParameterValueFromQuery(query, WL_RESULT);
              JSONObject jsonResult = new JSONObject(result);
  
              // process failures if any
              JSONObject jsonFailures = jsonResult.optJSONObject(AUTH_FAILURE_VALUE_NAME);
  
              if (jsonFailures != null) {
                  processFailures(jsonFailures);
                  listener.onFailure(response, null, null);
                  return;
              }
  
              // process successes if any
              JSONObject jsonSuccesses = jsonResult.optJSONObject(AUTH_SUCCESS_VALUE_NAME);
  
              if (jsonSuccesses != null) {
                  processSuccesses(jsonSuccesses);
              }
          }
  
          // the rest is handles by the caller
          listener.onSuccess(response);
      }
docs: Processes redirect response from authorization endpoint.
  
  @param response Response from the server.