Hi,
I am trying to create an integration where the authorisation request that the API client request a token, then that token is used in a Bearer token for subsequent requests. As far as I understand, the Session Authentication type should be used of this, however, I am causing a 500 server error via Zapier. I have a successful authorisation mechanism setup in Postman, but can’t seem to replicate this in Zapier.
The API endpoint I am looking to use to request the token is https://cloudshare.stoplight.io/docs/AccelerateAPI/5jzyft1s3p00h-authentication
In Postman, the code I use to request the token is:
pm.sendRequest({
url: 'https://api.accelerate.cloudshare.com/v4/oauth/token',
method: 'POST',
header: 'Content-Type: application/x-www-form-urlencoded',
body: {
mode: 'urlencoded',
urlencoded: d
// The CloudShare Oauth2 implemntaiton is the same as using "Client Credentiatls" in the built in Postman Oauth2 authorisation
{ key: "client_id", value: pm.variables.get("API_ID"), disabled: false },
{ key: "client_secret", value: pm.variables.get("API_KEY"), disabled: false },
{ key: "grant_type", value: "client_credentials", disabled: false }
]
}
}
This result in a body that is sent similar to the following:
In Zapier, I switched to use the code view for the authentication, and even hard coded the `client_id` and `client_secret` values (as I couldn’t get the form parameter to work) but I could not get this to work in any case. It now looks like:
Test the authentication I see:
authentication failed: The app returned "Action failed". What happened (You are seeing this because you are an admin): Stack trace: ResponseError: {"status":500,"headers":{"content-type":"application/json; charset=utf-8","retry-after":null},"content":"{\"message\":\"Action failed\",\"code\":\"0x50001\"}","request":{"url":"https://api.accelerate.cloudshare.com/v4/oauth/token"}} at _throwForStatus (/var/task/node_modules/zapier-platform-core/src/http-middlewares/after/prepare-response.js:13:11) at outResp.throwForStatus (/var/task/node_modules/zapier-platform-core/src/http-middlewares/after/prepare-response.js:68:5) at throwForStatusMiddleware (/var/task/node_modules/zapier-platform-core/src/http-middlewares/after/throw-for-status.js:5:14) at Object.<anonymous> (/var/task/node_modules/zapier-platform-core/src/middleware.js:80:37) From previous event: at /var/task/node_modules/zapier-platform-core/src/middleware.js:77:26 at Array.reduce (<anonymous>) at afterMiddleware (/var/task/node_modules/zapier-platform-core/src/middleware.js:76:21) at Object.<anonymous> (/var/task/node_modules/zapier-platform-core/src/middleware.js:94:18) From previous event: at Object.<anonymous> (/var/task/node_modules/zapier-platform-core/src/middleware.js:92:10) From previous event: at /var/task/node_modules/zapier-platform-core/src/middleware.js:89:45 at /var/task/node_modules/zapier-platform-core/src/tools/create-lambda-handler.js:212:18 at bound (node:domain:433:15) at runBound (node:domain:444:12) at process.processImmediate (node:internal/timers:476:21) at process.topLevelDomainCallback (node:domain:161:15) at process.callbackTrampoline (node:internal/async_hooks:126:24) From previous event: at Domain.<anonymous> (/var/task/node_modules/zapier-platform-core/src/tools/create-lambda-handler.js:196:10) at Domain.run (node:domain:389:15) at Runtime.handler (/var/task/node_modules/zapier-platform-core/src/tools/create-lambda-handler.js:192:19) at Runtime.handleOnceNonStreaming (file:///var/runtime/index.mjs:1173:29)
Any thoughts?
One the raw access token retravl is working, the next step to to use the response JSON that contains the `access_token` as a Bearer token with follow up requests (then refresh the token every 300 seconds as required).