code: public void authenticate(HttpURLConnection httpConn, String url) {
          String authorization = null;
          if (hasAccessToken() && isOperationOauth(url)) {
              logger.debug("Using OAuth token to authenticate");
              authorization = getAccessTokenType() + " " + getAccessToken();
          } else if (hasApiKey()) {
              logger.debug("Using API Key to authenticate");
              String apiKey = getApiKey() + ":";
              authorization = "Basic " + DatatypeConverter.printBase64Binary(apiKey.getBytes()).trim();
          }
          if (authorization != null) {
              logger.debug("Authorization: " + authorization);
              httpConn.setRequestProperty("authorization", authorization);
          }
      }
docs: Authorizes the HTTP connection using this instance's credentials.
  
  @param httpConn HttpURLConnection to be authenticated
  @param url String URL against which this connection should be authorized.