Hello, I have been struggling with this for a while.
basically I want the user to enter client_id, client_secret, grant_type and scope when creating a new connection, The connection should then get the token using this data, but it does not seem to be doing that.
code below is one thing I have tried, also tried to put the body in seperate objects wihtout any luck. I also tried to set the type to other things.
I don’t get any errors when add the connection but I always get back 401 not authorized when I run the module.
I have been looking for a way how to see the request from the token fetch but that seem to deeply hidden somewhere at makes servers.
When I look in dev tools plugin I see the same as in the ui, 401 error.
there is nothing wrong with the service, I can successully get the token using both postman and curl
what am I doing wrong and how do I see what’s going on during the connection request?
CONNECTION
{
"type": "other",
"authorize": {
// Not needed for client credentials grant (no user redirection)
},
"token": {
"url": "https://connect.visma.com/connect/token",
"method": "POST",
"headers": {
"Content-Type": "application/x-www-form-urlencoded"
},
"body": "client_id={{parameters.client_id}}&client_secret={{parameters.client_secret}}&grant_type={{parameters.grant_type}}&scope={{parameters.scope}}",
"response": {
// Directly map the access_token to the connection object
"accessToken": "{{body.access_token}}"
}
},
"info": {
// Optional: Validate the token by making a test API call
"url": "https://business.visma.net/api/graphql-service",
"method": "POST",
"body": {
"query": "query { availableCompanies { totalCount } }"
},
"headers": {
"Authorization": "Bearer {{connection.accessToken}}"
}
}
}
BASE
{
"baseUrl": "https://business.visma.net/api/graphql-service",
"headers": {
"Authorization": "Bearer {{connection.accessToken}}",
"Content-Type": "application/json"
},
"body": {
"query": "query { availableCompanies { totalCount } }"
},
"response": {
"valid":"{{!body.error}}",
"error": {
"message": "Base Error[{{statusCode}}] {{body.error}} {{body.detail}} AccessToken: {{connection.accessToken}} {{connection.token}}"
}
}
}