iachat/app/services/twilio
Tanmay Deep Sharma 3c8abd5b30
fix: Twilio authentication handling for WhatsApp attachments (#11536)
# Pull Request Template

## Description

This PR addresses an issue where users were unable to view images sent
via WhatsApp on Chatwoot due to incorrect Twilio authentication
configuration.
https://app.chatwoot.com/app/accounts/1/conversations/50824

The problem stemmed from how authentication was being handled for Twilio
API requests. The user had configured their inbox using api_key_sid, but
the backend logic used only auth_token, leading to failed
authentication. Further investigation showed that some customers might
input api_secret into the auth_token field unintentionally.

## Type of change

- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality not to work as expected)
- [ ] This change requires a documentation update

## How Has This Been Tested?

- Tested on console with Client(api_key_sid, auth_token, account_sid)
and validated successful authentication for the customer (Twilio channel
ID: 2702).
- Simulated toggling the “Use API Key Authentication” checkbox to ensure
backend behavior matches UI intent
- Verified image rendering by testing with the same image URL that was
previously failing for the user.

## Checklist:

- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my code
- [x] I have commented on my code, particularly in hard-to-understand
areas
- [x] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [x] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes
- [x] Any dependent changes have been merged and published in downstream
modules

---------

Co-authored-by: Muhsin Keloth <muhsinkeramam@gmail.com>
2025-05-21 18:40:15 +05:30
..
delivery_status_service.rb fix: Change the message status to failed if the Twilio message delivery status is undelivered (#8097) 2023-10-12 15:27:38 +05:30
incoming_message_service.rb fix: Twilio authentication handling for WhatsApp attachments (#11536) 2025-05-21 18:40:15 +05:30
oneoff_sms_campaign_service.rb feat: Support Twilio Messaging Services (#4242) 2022-07-08 18:20:07 +05:30
send_on_twilio_service.rb feat: API Endpoints to update message status (#11387) 2025-04-29 15:33:11 -07:00
webhook_setup_service.rb feat: Allow Twilio::REST::TwilioError errors to raise and prevent Inbox creation (#7379) 2023-08-16 15:00:02 -07:00