messagebird-nodejs icon indicating copy to clipboard operation
messagebird-nodejs copied to clipboard

Error: Signatures not match.

Open thoaif opened this issue 4 years ago • 0 comments

Hi,

I am trying to set up the webhook for SMS status report, and I have tried the example setup in the docs. I am able to receive a GET request tunneled through ngrok, but I keep encountering "Error: Signatures not match."

Here is stack trace:

Error: Signatures not match.
    at validate (/home/user/messagebird-example/node_modules/messagebird/lib/signature.js:124:11)
    at signatureMiddleware (/home/user/messagebird-example/node_modules/messagebird/lib/signature.js:143:7)
    at Layer.handle [as handle_request] (/home/user/messagebird-example/node_modules/express/lib/router/layer.js:95:5)
    at next (/home/user/messagebird-example/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/home/user/messagebird-example/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/home/user/messagebird-example/node_modules/express/lib/router/layer.js:95:5)
    at /home/user/messagebird-example/node_modules/express/lib/router/index.js:281:22
    at Function.process_params (/home/user/messagebird-example/node_modules/express/lib/router/index.js:335:12)
    at next (/home/user/messagebird-example/node_modules/express/lib/router/index.js:275:10)
    at rawParser (/home/user/messagebird-example/node_modules/body-parser/lib/types/raw.js:67:7)

and here is the minimal server code I am using:

const express = require('express')

const app = express()

const Signature = require('messagebird/lib/signature')

const verifySignature = new Signature(process.env.SIGNING_KEY)

app.use(require('body-parser').raw({ type: '*/*' }))

app.get('/webhook', verifySignature, function (req, res) {
  res.send('Verified')
})

const port = process.env.PORT || 3000
app.listen(port, () => {
  console.log(`Running at http://localhost:${port}`)
})

I have spent hours trying to debug this issue, including regenerating signing keys, using different routes, etc. Could you please help? Thanks.

thoaif avatar Feb 20 '21 18:02 thoaif