diff --git a/connectors/http-json/README.md b/connectors/http-json/README.md
index 0b2f634ebb..846fbe979b 100644
--- a/connectors/http-json/README.md
+++ b/connectors/http-json/README.md
@@ -106,6 +106,34 @@ The response will contain the status code, the headers and the body of the respo
}
```
+### Input (OAuth)
+
+```json
+{
+ "method": "post",
+ "url": "https://youroauthclientdomainname.eu.auth0.com/oauth/token",
+ "authentication": {
+ "oauthTokenEndpoint":"secrets.OAUTH_TOKEN_ENDPOINT_KEY",
+ "scopes": "read:clients read:users",
+ "audience":"secrets.AUDIENCE_KEY",
+ "clientId":"secrets.CLIENT_ID_KEY",
+ "clientSecret":"secrets.CLIENT_SECRET_KEY",
+ "type": "oauth-client-credentials-flow",
+ "clientAuthentication":"secrets.CLIENT_AUTHENTICATION_KEY"
+ }
+}
+```
+
+### Output (Access Token)
+
+```json
+{
+ "access_token":"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCIsImtpZCI6IlUtN2N6WG1sMzljUFNfUnlQQkNMWCJ9.kjhwfjkhfejkrhfbwjkfbhetcetc",
+ "scope":"read:clients create:users",
+ "expires_in":86400,
+ "token_type":"Bearer"
+}
+```
### Error codes
The Connector will fail on any non-2XX HTTP status code in the response. This error status code will be passed on as error code, e.g. "404".
diff --git a/connectors/http-json/element-templates/http-json-connector.json b/connectors/http-json/element-templates/http-json-connector.json
index 36543fdc15..578e8d44d2 100644
--- a/connectors/http-json/element-templates/http-json-connector.json
+++ b/connectors/http-json/element-templates/http-json-connector.json
@@ -251,9 +251,6 @@
"type": "zeebe:input",
"name": "authentication.audience"
},
- "constraints": {
- "notEmpty": true
- },
"condition": {
"property": "authenticationType",
"equals": "oauth-client-credentials-flow"
diff --git a/connectors/http-json/pom.xml b/connectors/http-json/pom.xml
index ba0bc7235c..4173032448 100644
--- a/connectors/http-json/pom.xml
+++ b/connectors/http-json/pom.xml
@@ -186,7 +186,7 @@
io.camunda.connector
connector-runtime-cloud
- 0.4.0-SNAPSHOT
+ 0.3.0
io.camunda.connector
diff --git a/connectors/http-json/src/main/java/io/camunda/connector/http/HttpJsonFunction.java b/connectors/http-json/src/main/java/io/camunda/connector/http/HttpJsonFunction.java
index 183df23ac6..a2a6fbceef 100644
--- a/connectors/http-json/src/main/java/io/camunda/connector/http/HttpJsonFunction.java
+++ b/connectors/http-json/src/main/java/io/camunda/connector/http/HttpJsonFunction.java
@@ -26,7 +26,7 @@
import com.google.api.client.http.HttpRequestFactory;
import com.google.api.client.http.HttpResponse;
import com.google.api.client.http.HttpResponseException;
-import com.google.api.client.http.json.JsonHttpContent;
+import com.google.api.client.http.UrlEncodedContent;
import com.google.api.client.json.gson.GsonFactory;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
@@ -147,19 +147,19 @@ protected HttpRequest createOAuthRequest(HttpJsonRequest request) throws IOExcep
final GenericUrl genericUrl = new GenericUrl(authentication.getOauthTokenEndpoint());
Map data = getDataForAuthRequestBody(authentication);
- HttpContent content = new JsonHttpContent(gsonFactory, data);
+ HttpContent content = new UrlEncodedContent(data);
final String method = Constants.POST;
-
final var httpRequest = requestFactory.buildRequest(method, genericUrl, content);
httpRequest.setFollowRedirects(false);
setTimeout(request, httpRequest);
+ HttpHeaders headers = new HttpHeaders();
if (authentication.getClientAuthentication().equals(Constants.BASIC_AUTH_HEADER)) {
- HttpHeaders headers = new HttpHeaders();
headers.setBasicAuthentication(
authentication.getClientId(), authentication.getClientSecret());
- httpRequest.setHeaders(headers);
}
+ headers.setContentType(Constants.APPLICATION_X_WWW_FORM_URLENCODED);
+ httpRequest.setHeaders(headers);
return httpRequest;
}
@@ -202,7 +202,7 @@ protected HttpJsonResult executeRequestViaProxy(String proxyUrl, HttpJsonRequest
// hence write it ourselves:
String contentAsJson = gson.toJson(request);
HttpContent content =
- new AbstractHttpContent("application/json; charset=UTF-8") {
+ new AbstractHttpContent(Constants.APPLICATION_JSON_CHARSET_UTF_8) {
public void writeTo(OutputStream outputStream) throws IOException {
outputStream.write(contentAsJson.getBytes(StandardCharsets.UTF_8));
}
@@ -258,7 +258,7 @@ protected void setTimeout(HttpJsonRequest request, HttpRequest httpRequest) {
protected HttpContent createContent(final HttpJsonRequest request) {
if (request.hasBody()) {
- return new JsonHttpContent(gsonFactory, request.getBody());
+ return new UrlEncodedContent(request.hasBody());
} else {
return null;
}
diff --git a/connectors/http-json/src/main/java/io/camunda/connector/http/constants/Constants.java b/connectors/http-json/src/main/java/io/camunda/connector/http/constants/Constants.java
index 0b0e089b6a..0f29108410 100644
--- a/connectors/http-json/src/main/java/io/camunda/connector/http/constants/Constants.java
+++ b/connectors/http-json/src/main/java/io/camunda/connector/http/constants/Constants.java
@@ -28,4 +28,7 @@ public class Constants {
public static final String CREDENTIALS_BODY = "credentialsBody";
public static final String PROXY_FUNCTION_URL_ENV_NAME = "CAMUNDA_CONNECTOR_HTTP_PROXY_URL";
public static final String POST = "POST";
+ public static final String APPLICATION_JSON_CHARSET_UTF_8 = "application/json; charset=UTF-8";
+ public static final String APPLICATION_X_WWW_FORM_URLENCODED =
+ "application/x-www-form-urlencoded";
}