Hello,
I am trying to make a custom app that first get a token using the connection and then gets the data using the module
I am currenly not using any sanitation or parameters and kept the code to a minumum because I first want to make sure it is running.
My custom app consist of three object, the Base, the Connection and the Module. The connection is connected to the module.
here is my problem
step 1.
When I add the app to the scenario and add a connection I get no error but I also get no info at all, it all looks ok but nothing in devlog or make log. At this step a window popups up like it is doing an oauth2 connection but without any data, it closes after a few seconds, not sure why it does that and why it is not just trying to fetch the token in the background. there should be NO “man in the middle” action in this request.
step 2.
when I run the module I get “401 Authorization Required” indicating that the request did not send any token, and the make devtool says it was a response without proceeding request.
If I replace the {{connection.accessToken}} in the base with the actual token (fetched using postman) it works fine.
so the problem I am facing is either
- The token is never fetched correctly
- the token is fetched but not passed to the base correctly.
I also want to point out that I have spent a lot of time on this and have tried all the different connection templates.
I also tried to edit the apps using the vscode extension and tried all the samples in there as well.
This is the base
{
"baseUrl": "https://business.visma.net/api/graphql-service",
"headers": {
"Authorization": "Bearer {{connection.accessToken}}"
},
"response": {
"error": {
"type": "{{body.code}}",
"message": "Base Errror {{body.message}}"
},
"valid": "Valid: {{if(body.code, false, true)}} token: {{connection.accessToken}}"
}
}
This is the connection
{
"token": {
"url": "https://connect.visma.com/connect/token",
"method": "POST",
"headers": {
"Content-Type": "application/x-www-form-urlencoded"
},
"body": {
"client_id": "",
"client_secret": "",
"scope": "",
"grant_type": ""
},
"type": "urlencoded",
"response": {
"type":"json",
"data": {
"accessToken": "{{body.access_token}}",
"expires": "{{addSeconds(now, body.expires_in)}}"
},
"error": {
"type": "DataError",
"message": "[{{statusCode}}] {{body.message}}"
}
}
}
}
This is the module
{
"url":"/",
"method": "POST",
"body": {
"query": "query { availableCompanies { totalCount items { name vismaNetCompanyId vismaNetCustomerId}}}"
},
"response": {
"output": "{{body}}",
"error": {
"type": "ModuleError",
"message": "Module Errror - Status: [{{statusCode}}] Message: {{body.message}} Body: {{body}}"
}
}
}
This is make devtools error
{
"type": "error",
"array": "Module Errror - Status: [401] Message: <html>\r\n<head><title>401 Authorization Required</title></head>\r\n<body>\r\n<center><h1>401 Authorization Required</h1></center>\r\n<hr><center>nginx</center>\r\n</body>\r\n</html>\r\n Body: <html>\r\n<head><title>401 Authorization Required</title></head>\r\n<body>\r\n<center><h1>401 Authorization Required</h1></center>\r\n<hr><center>nginx</center>\r\n</body>\r\n</html>\r\n",
"_engineData": {
"calledAt": "Not available"
}
}
what can be the issue I am facing?
thanks
Thomas