code: public static Map<String, Object> createFormParamPasswordGrantType(String username, String password, String scope, String clientId) {
          if (username == null) {
              throw new IllegalArgumentException("Missing the required parameter 'username'");
          }
          if (password == null) {
              throw new IllegalArgumentException("Missing the required parameter 'password'");
          }
          Map<String, Object> formParams = new HashMap<>();
          formParams.put("grant_type", "password");
          formParams.put("username", username);
          formParams.put("password", password);
          if (clientId != null) {
              formParams.put("client_id", clientId);
          }
          if (scope != null) {
              formParams.put("scope", scope);
          }
          return formParams;
      }
docs: Build form parameters
  
  @param username The agent&#39;s username.
  @param password The agent&#39;s password.
  @param scope    The scope of the access request. The Authentication API supports only the &#x60;*&#x60; value. (optional)
  @param clientId The ID of the application or service that is registered as the client. You&#39;ll need to get this value from your PureEngage Cloud representative. (optional)
  @return a map of form parameters
  @throws IllegalArgumentException if required form parameters are missed