Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TCHMessageBuilder.addMedia() fails authentication #47

Open
twoeven opened this issue Oct 19, 2023 · 0 comments
Open

TCHMessageBuilder.addMedia() fails authentication #47

twoeven opened this issue Oct 19, 2023 · 0 comments

Comments

@twoeven
Copy link

twoeven commented Oct 19, 2023

Also submitted as support ticket #13959800 with more details.

This can be demonstrated using the twilio-conversations-demo-ios-swift project. All participants are chat. Sending basic messages, push notifications, editing metadata, all works correctly. However, when attaching media via TCHMessageBuilder.addMedia() the upload fails with Domain=signal.sdk.domain.error Code=4010 "No authentication provided".

This appears to be related to my production twilio account which has HIPAA features, as the same error does not happen in my development account. Uploading the media via the REST api works (example below), but I would prefer to stay in the framework.

Same behavior observed in TwilioConversationsClient 2.x and 3.1.0 (preferred) and 4.0.2

Excerpt from the trace log demonstrating the error:

2023-10-18 10:57:56.886837-0500 Chat[34765:4184601] <<<<TwilioConversationsClient: 0x600001588380>>>> -      | websocket  | sendMessage_block_invoke: frame sent successfully
2023-10-18 10:57:56.948775-0500 Chat[34765:4184601] <<<<TwilioConversationsClient: 0x600001588380>>>> -   15 | Twilsock connected | notifyMessageReceived
2023-10-18 10:57:56.948869-0500 Chat[34765:4184601] <<<<TwilioConversationsClient: 0x600001588380>>>> -    2 | Twilsock Client | onMessageReceived (595)
TWILSOCK V3.0 552
{"method":"reply","id":"RQcf7f25b2727444a8b5c07e8904768f0a","payload_size":20,"payload_type":"application/json","status":{"code":200,"status":"OK"},"http_headers":{"server":"envoy","date":"Wed, 18 Oct 2023 15:57:56 GMT","content-type":"application/json","content-length":"20","i-twilio-upstream-request-id":"RUa4dbcbcb022047f490c8a844de63bba7","i-twilio-request-id":"RQa81888af03564916b5560fe9ef2f7662","x-shenanigans":"none","strict-transport-security":"max-age=31536000","x-envoy-upstream-service-time":"26"},"http_status":{"code":200,"status":"OK"}}
{"typing_timeout":5}
2023-10-18 10:57:56.948937-0500 Chat[34765:4184601] <<<<TwilioConversationsClient: 0x600001588380>>>> -    2 | Twilsock Client | onMessageReceived, method = 6, id = RQcf7f25b2727444a8b5c07e8904768f0a
2023-10-18 10:57:56.948987-0500 Chat[34765:4184601] <<<<TwilioConversationsClient: 0x600001588380>>>> -    2 | Twilsock Client | processReplyMessage in state Connected , RQcf7f25b2727444a8b5c07e8904768f0a
2023-10-18 10:57:56.952994-0500 Chat[34765:4184601] <<<<TwilioConversationsClient: 0x600001588380>>>> -    2 | Twilsock Client | Reply for 'RQcf7f25b2727444a8b5c07e8904768f0a', code=200
2023-10-18 10:57:56.953056-0500 Chat[34765:4184601] <<<<TwilioConversationsClient: 0x600001588380>>>> -    2 | Twilsock Client | handleReply in state Connected : 'message' message succeeded
2023-10-18 10:57:56.953100-0500 Chat[34765:4184601] <<<<TwilioConversationsClient: 0x600001588380>>>> -  126 | Twilsock UpstreamMessageResultObserver | onSuccess(200, OK) https://aim.us1.twilio.com/v1/Instances/IS3b0b7c7018cb4ef4955ba8dfd2d6d1e8/Typing
2023-10-18 10:57:56.953155-0500 Chat[34765:4184601] <<<<TwilioConversationsClient: 0x600001588380>>>> -      | Http HttpResponse.ctor | payload '{"typing_timeout":5}'
2023-10-18 10:57:56.953210-0500 Chat[34765:4184601] <<<<TwilioConversationsClient: 0x600001588380>>>> -      | Chat IPM | got response from typing service: {"typing_timeout":5}
2023-10-18 10:58:01.887293-0500 Chat[34765:4184601] <<<<TwilioConversationsClient: 0x600001588380>>>> -      | Chat IPM | [YPfiU] typing state: StateTypingOutgoingDeny -> StateTypingOutgoingAllow
2023-10-18 10:58:09.813162-0500 Chat[34765:4184601] <<<<TwilioConversationsClient: 0x600001588380>>>> -      | Chat IPM | [1YT3H] got channel from cache CH493cb3c6c90d4c2e8fd91584886772e4
2023-10-18 10:58:09.813262-0500 Chat[34765:4184601] <<<<TwilioConversationsClient: 0x600001588380>>>> -      | Chat IPM | channels: got from cache CH493cb3c6c90d4c2e8fd91584886772e4
[MediaMessage] Media upload started
🎦 didSendBodyData: 1048745, totalBytesSent: 1048745, totalBytesExpectedToSend: -1
[MediaMessage] Current progress 1048532
🎦 didSendBodyData: 803730, totalBytesSent: 1852475, totalBytesExpectedToSend: -1
[MediaMessage] Current progress 1852262
🎦 Decoded data {"message":"No authentication provided","code":4010,"user_error":true,"http_status_code":-1,"params":{}}
🎦 Response code: 401
[MediaMessage] upload failed with error Error Domain=signal.sdk.domain.error Code=4010 "No authentication provided" UserInfo={NSLocalizedDescription=No authentication provided}
2023-10-18 10:58:10.264232-0500 Chat[34765:4184553] Error encountered while sending media message: Error Domain=signal.sdk.domain.error Code=-1 "Cannot upload one or more media files" UserInfo={kTCHErrorMsgKey=Cannot upload one or more media files, NSLocalizedDescription=Cannot upload one or more media files}

I confirmed that I am able to upload media to this service using the REST api.

$ curl -u "SKxxx:xxx" --data-binary "@images/[email protected]" https://mcs.us1.twilio.com/v1/Services/ISxxx/Media

{"sid":"MExxx","service_sid":"ISxxx","date_created":"2023-10-18T15:16:12.466094Z","date_upload_updated":"2023-10-18T15:16:12.47019Z","date_updated":"2023-10-18T15:16:12.466094Z","links":{"content":"/v1/Services/ISxxx/Media/MExxx/Content"},"size":8228,"content_type":"application/x-www-form-urlencoded","filename":null,"author":"system","category":"media","message_sid":null,"channel_sid":null,"url":"/v1/Services/ISxxx/Media/MExxx","is_multipart_upstream":false}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants