code: public String getAuthString() {
          String credentials = this.username + ":" + this.password;
          try {
  
              String encoded = new Base64().encodeAsString(credentials.getBytes("ascii"));
              return "Basic " + encoded;
  
          } catch (final UnsupportedEncodingException e) {
  
              throw new InvalidRequestException("It must be possible to encode credentials as ascii", credentials, e);
  
          }
      }
docs: Create auth string from username and password.
  
  @return basic authentication string