docker icon indicating copy to clipboard operation
docker copied to clipboard

Zapier connection "API key not valid"

Open RaminGe opened this issue 1 year ago • 1 comments

Hey there,

when trying to connect our self-hosted cal.com with zapier, I always get this error:

authentication failed: The app returned “API key not valid”. What happened (You are seeing this because you are an admin): Stack trace: ResponseError: {“status”:401,“headers”:{“content-type”:“application/json; charset=utf-8”,“retry-after”:null},“content”:“{\“message\“:\“API key not valid\“}”,“request”:{“url”:“https://XXXXX/api/integrations/zapier/listBookings?apiKey=cal_XXXX”}} 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. (/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 () at afterMiddleware (/var/task/node_modules/zapier-platform-core/src/middleware.js:76:21) at Object. (/var/task/node_modules/zapier-platform-core/src/middleware.js:94:18) From previous event: at Object. (/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. (/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)

I don't have a clue why. Is there anything which needs to be configured to get it up and running with the docker self-hosted variant? I followed these steps: https://github.com/calcom/cal.com/tree/main/packages/app-store/zapier

Also updated to the newest version (4.0.5) and tried it, getting the same error.

Thanks for your help!

RaminGe avatar May 02 '24 19:05 RaminGe

Any update on this? Did you find a solution to this issue?

2025-06-06 EDIT: Found the issue... createHandler uses cal_ as fallback value if environment variable API_KEY_PREFIX is not set, but the validation uses substring(0) instead of substring(4) for validation.

I wonder how there aren't more issues about this without any fix...

SOLUTION: If you don't want to change the codebase, easiest workaround is to set the environment variable API_KEY_PREFIX to any value, even if it is just cal_.

Nymu5 avatar Jun 06 '25 20:06 Nymu5