Error Data Actions

Hello,

We have configured an integration through webservices authenticating with oauth with the client and the secret that the client has given us, when doing the data action we add the token that they have given us, and we get this error, which can be?

They using Oauth2.

{
"message": "No authentication bearer token specified in authorization header.",
"code": "authentication.required",
"status": 401,
"messageParams": {},
"contextId": "7595fcb5-e346-487e-a7ad-f81326bb171b",
"details": [
{
"errorCode": "ACTION.REMOTE_ENDPOINT"
}
],
"errors": [
{
"message": "REST call for action execute failed. Message:Request to backend service failed. Response from web service: {"code":"AUTHENTICATION_FAILURE","details":{},"message":"Authentication failed","status":"error"}\n [7595fcb5-e346-487e-a7ad-f81326bb171b]",
"code": "AUTHENTICATION_REQUIRED",
"status": 401,
"messageParams": {},
"details": [],
"errors": []
}
]
}

Can you provide an export of the data action (without the client ID and secret) so we can see what is going on?

{
"name": "Web Services Data Actions (1) (Auth) - Exported 2020-03-03 @ 16:00",
"integrationType": "custom-rest-actions",
"actionType": "customAuth",
"config": {
"request": {
"requestUrlTemplate": "https://accounts.zoho.eu/oauth/v2/token?refresh_token={refresh_token}&client_id={client_id}&client_secret={client_secret}&grant_type=refresh_token",
"requestType": "POST",
"headers": {
"Authorization": "Basic encoding.base64(\"{credentials.client_Id}:{credentials.client_Secret}\")", "Content-Type": "application/x-www-form-urlencoded" }, "requestTemplate": "grant_type=client_credentials" }, "response": { "translationMap": {}, "translationMapDefaults": {}, "successTemplate": "{rawResult}"
}
},
"contract": {
"input": {
"inputSchema": {
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Auth Input",
"description": "No Input Value",
"type": "object",
"properties": {}
}
},
"output": {
"successSchema": {
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {},
"additionalProperties": true
}
}
},
"secure": false
}

now he gives us this mistake and we don't know what's wrong.

{
"message": "The request could not be understood by the server due to malformed syntax.",
"code": "bad.request",
"status": 400,
"messageParams": {},
"contextId": "c03ad0b0-ac19-474a-a63d-3fc40d2d54ac",
"details": [
{
"errorCode": "ACTION.PROCESSING"
}
],
"errors": [
{
"message": "Failed due to malformed requestUrlTemplate. Illegal character in query at index 54: https://accounts.zoho.eu/oauth/v2/token?refresh_token={refresh_token}&client_id={client_id}&client_secret={client_secret}&grant_type=refresh_token",
"code": "BAD_REQUEST",
"status": 400,
"messageParams": {},
"details": [],
"errors": []
}
]
}

There look to be a couple of issues with your variable substitution.

Take a look at this page:

Specifically, the example authorization header:
"Authorization": "Basic encoding.base64(\"{credentials.clientId}:${credentials.clientSecret}")",

Note that variables in the custom auth action have a in front of the { for a variable, and that the variables are in the form {credentials.foo}

Hello,

where exactly do you see the flaw?

thnx

I'm still getting this mistake, too:

{
"message": "The request could not be understood by the server due to malformed syntax.",
"code": "bad.request",
"status": 400,
"messageParams": {},
"contextId": "52356cb0-fc51-4bc7-92bd-2adec2e55f18",
"details": [
{
"errorCode": "ACTION.PROCESSING"
}
],
"errors": [
{
"message": "Failed due to malformed requestUrlTemplate. Illegal character in query at index 54: https://accounts.zoho.eu/oauth/v2/token?refresh_token={refresh_token}&client_id={client_id}&client_secret={client_secret}&grant_type=refresh_token",
"code": "BAD_REQUEST",
"status": 400,
"messageParams": {},
"details": [],
"errors": []
}
]
}

I see at least the following errors:
{refresh_token}
{client_id}
{client_secret}

It would also be easier to see what is going on if you would export your action and attach the file to this thread.

Web-Services-Data-Actions-2-Auth-20200303163608.customAuth.json (1.2 KB)

Upload

thnks

Your Request URL template contains
{refresh_token}
{client_id}
{client_secret}

that all need to be updated.

Looking at the docs I could find for this I don't think you are expected to include an authorization header

It also looks like you can empty out the request template.

Finally, the documentation indicates that you need a "Authorized Redirect URI", however the example doesn't include one so I'm not sure what to do with that.

If I do not include in the integration of webservice, in the section credentials the token of authorization, indicates me this error.

{
"message": "The request could not be understood by the server due to malformed syntax.",
"code": "bad.request",
"status": 400,
"messageParams": {},
"contextId": "ab6876ea-5de0-440b-ab87-6b563dcc0c6a",
"details": [
{
"errorCode": "ACTION.PROCESSING"
}
],
"errors": [
{
"message": "Failed due to malformed requestUrlTemplate. Illegal character in query at index 54: ",
"code": "BAD_REQUEST",
"status": 400,
"messageParams": {},
"details": [],
"errors": []
}
]
}

Is correct body?

{
"requestUrlTemplate": "https://accounts.zoho.eu/oauth/v2/token?refresh_token={refresh_token}&client_id={client_id}&client_secret={client_secret}&grant_type=refresh_token",
"requestType": "POST",
"headers": {
"Authorization": "Basic encoding.base64(\"{credentials.clientId}:${credentials.clientSecret}")",
"Content-Type": "application/x-www-form-urlencoded"
},
"requestTemplate": "grant_type=refresh_token"
}

As far as I can tell, you are still missing the $ before the {

It looks like the forum is sometimes messing up the special characters.

Also, based on the documentation it doesn't appear that you need anything in the request template.

Hello,

Where do you think the $ is missing?

It's still not working and it's still making the same mistake.

{
"message": "The request could not be understood by the server due to malformed syntax.",
"code": "bad.request",
"status": 400,
"messageParams": {},
"contextId": "8af4e7b7-91d2-4889-87de-ac58e823aa88",
"details": [
{
"errorCode": "ACTION.PROCESSING"
}
],
"errors": [
{
"message": "Failed due to malformed requestUrlTemplate. Illegal character in query at index 54: ",
"code": "BAD_REQUEST",
"status": 400,
"messageParams": {},
"details": [],
"errors": []
}
]
}

I can't download the json for the action anymore but from what you posted some of your variables does not have $.

e.g. Instead of {refresh_token} it should be ${refresh_token}.

Everytime you enclose a variable in {} it should be prepended with $.

Hello,

If I add the $ between {}, it gives us this error.

Resolve request URL template: Substitution values invalid in action config. Variable $refresh_token has not been set at UrlTemplate[line 1, column 55] A common reason for this error is needing to prepend the variable with 'input.' or 'credentials.'

It depends where you're getting those values. If you've defined it in the Data Action Input contract then it's ${input.refresh_token}, if you've set the credentials for the Integration then it would be like ${credentials.client_id}

In the integration data I set

loginUrl
clientId
clientSecret
refresh_token

and these are the details of the request

{
"requestUrlTemplate": "${credentials.loginUrl}"
"requestType": "POST",
"headers": {
"Authorization": "Basic encoding.base64({credentials.clientId:${credentials.clientSecret}",
"Content-Type": "application/x-www-form-urlencoded"
},
"requestTemplate": "grant_type=client_credentials"
}

Documentation:

Then in the input of the data action we add an input field, refresh_token?

Thnks

The resource article is just an example on how one may authenticate with an OAuth service. In your case, at least based on the documentation Jason posted, you won't need the Authorization header since Zoho is asking for the credentials in the URI itself as part of the query parameters.

Try this as your requestUrlTemplate
https://accounts.zoho.eu/oauth/v2/token?refresh_token=${credentials.refresh_token}&client_id=${credentials.client_id}&client_secret=${credentials.client_secret}&grant_type=refresh_token