claudiajs / claudia-bot-builder

Create chat bots for Facebook Messenger, Slack, Amazon Alexa, Skype, Telegram, Viber, Line, GroupMe, Kik and Twilio and deploy to AWS Lambda in minutes
https://claudiajs.com/claudia-bot-builder.html
MIT License
1.84k stars 253 forks source link

line replyToken invalid #88

Closed yipcma closed 7 years ago

yipcma commented 7 years ago
{ headers:
   { server: 'nginx',
     'content-type': 'application/json;charset=UTF-8',
     'x-line-request-id': '784ef36e-e864-4884-a8b5-fc883e7142fd',
     'x-content-type-options': 'nosniff',
     'x-xss-protection': '1; mode=block',
     'x-frame-options': 'DENY',
     'content-length': '94',
     expires: 'Mon, 13 Feb 2017 09:46:47 GMT',
     'cache-control': 'max-age=0, no-cache, no-store',
     pragma: 'no-cache',
     date: 'Mon, 13 Feb 2017 09:46:47 GMT',
     connection: 'close' },
  body: '{"message":"The property, \'replyToken\', in the request body is invalid (line: 1, column: 15)"}',
  statusCode: 400,
  statusMessage: 'Bad Request' }
yipcma commented 7 years ago

Would love to follow up on line basic integration @simalexan

stojanovic commented 7 years ago

@yipcma can you send PR for this?

yipcma commented 7 years ago

@stojanovic I don't have any clue, been reading line docs but it's not helping.

cbrunnkvist commented 7 years ago

I'm going to need to do some Line integration in the coming week/s, will update this ticket in case I find any issues.

yipcma commented 7 years ago

this could be the issue with the encoding:

Signature validation

The signature in the X-Line-Signature request header must be verified to confirm that the request was sent from the LINE Platform.

Authentication is performed as follows.

With the Channel secret as the secret key, your application retrieves the digest value in the request body created using the HMAC-SHA256 algorithm. The server confirms that the signature in the request header matches the digest value which is Base64 encoded.

from https://devdocs.line.me/en/#webhooks

stojanovic commented 7 years ago

@yipcma I wrote to their support. It's not a signature issue, because signature is just a validation that message is received from Line, we don't need to send anything for that.

stojanovic commented 7 years ago

Finally! It was a content length header! Commit: https://github.com/claudiajs/claudia-bot-builder/commit/459625990d1f19b9e87f621275f7771fdcbca927