Not authorized File Message

Dear Sir,

I am not able to access file messages from chat SDK when I retrieve the response It shows Not Authorized. I am trying to fetch images in an open channel.

Hey @adarsh_sharma,

Welcome to the Sendbird Community. we’re happy you’re here! When you’re accessing the URL, are you accessing the signed url with the auth key attached to it? If not, you won’t be able to access the file.

-Tyler

@Tyler I am not getting the auth token in url. How can I get the file url with auth token… I read the solution from other question. It says we have request_auth params while sending file messages but It can only be changed my internal global setting. I don’t know what to do. please help me with this issue.

Help me with issue sir.

even I am giving the acces token permission to read & write

I apologize for the delayed response. Can you provide me with the object that is returned to you by Sendbird?

Thanks,
Tyler

Thanks for your response … see the response

{
        "_sender": {
            "_preferredLanguages": null,
            "connectionStatus": "nonavailable",
            "friendDiscoveryKey": null,
            "friendName": null,
            "isActive": true,
            "isBlockedByMe": false,
            "lastSeenAt": 0,
            "metaData": [
                "Object"
            ],
            "nickname": "",
            "plainProfileUrl": "",
            "requireAuth": false,
            "role": "operator",
            "userId": "74"
        },
        "channelType": "open",
        "channelUrl": "sendbird_open_channel_9484_4ca68a269183107d45f5e0d92f4034e3fddbebb2",
        "createdAt": 1615636378377,
        "customType": "",
        "data": "",
        "errorCode": 0,
        "isOperatorMessage": true,
        "mentionType": "users",
        "mentionedUsers": [],
        "messageId": 6688723924,
        "messageSurvivalSeconds": -1,
        "messageType": "file",
        "metaArrays": [],
        "name": "image-18356ab2-06d1-4dbc-b019-81e198a0011b.jpg",
        "ogMetaData": null,
        "parentMessageId": 0,
        "parentMessageText": null,
        "plainUrl": "https://file-us-3.sendbird.com/ed3c18a563e14fee81fdc5549b76f992.jpg",
        "reactions": [],
        "reqId": "1615636351644",
        "requestState": "succeeded",
        "requestedMentionUserIds": [],
        "requireAuth": true,
        "sendingStatus": "succeeded",
        "silent": false,
        "size": 3039781,
        "threadInfo": {
            "lastRepliedAt": 0,
            "mostRepliedUsers": [
                "Array"
            ],
            "replyCount": 0,
            "updatedAt": 0
        },
        "thumbnails": [],
        "type": "image/jpeg",
        "updatedAt": 0
    },

hear I am getting plainUrl ehis shows not authorized.

Hi,
Please help me for this case of sendFileMessage, my code as bellow:
//=====================//
let source = {“name”: “video”, “type”: “video/mov”, “uri”: “file:///var/mobile/Containers/Data/Application/49118119-D5EA-4392-98A8-415E016CB2DF/tmp/trim.202E8291-03F6-49E9-A31F-60F667C34CB0.MOV”};
let data = “”;
let customType = “video”;
sendFileMessage(
source,
data,
customType,
(message, error) => {
if (error) {
return null;
}
return message;
}
);

//============== with message response ====== //

{
“_sender”:{},
“appleCriticalAlertOptions”:null,
“channelType”:“group”,
“channelUrl”:“sendbird_group_channel_36251648_d1e71ec0b510391d2701de95b16add769fb43345”,
“createdAt”:1620744666135,
“customType”:“video”,
“data”:"",
“errorCode”:0,
“isOperatorMessage”:false,
“mentionType”:“users”,
“mentionedUsers”:[
],
“messageId”:1089096444,
“messageSurvivalSeconds”:-1,
“messageType”:“file”,
“metaArrays”:[
],
“name”:“Video”,
“ogMetaData”:null,
“parentMessageId”:0,
“parentMessageText”:null,
“plainUrl”:“https://file-ap-2.sendbird.com/3e81783a29ef4f1c956862e9061fe827.mov”,
“reactions”:[
],
“reqId”:“1620744638406”,
“requestState”:“succeeded”,
“requestedMentionUserIds”:[
],
“requireAuth”:true,
“sendingStatus”:“succeeded”,
“silent”:false,
“size”:693637,
“threadInfo”:{},
“thumbnails”:[
],
“type”:“video/mov”,
“updatedAt”:0
}

//====================//
I only received :
“plainUrl”:“https://file-ap-2.sendbird.com/3e81783a29ef4f1c956862e9061fe827.mov”,
And the url is Not authorized. when open.
Is there any way to set more params or enable auth to open the file or return the url to open/play

Ps:

  1. All configs turned on on Dashboard page
  2. const thumbSizeList = [{ maxWidth: 512, maxHeight: 512 }]; if I add this one then send the image file will work correctly and return list thumb urls, we can open and display it. But when add this one for upload video the error message returned: Error [SendBirdException: Invalid parameter.]
  3. JavaScript, React-native plaform (“react-native”: “0.64.0”, “sendbird”: “^3.0.148”)
  4. I’m using sendbird SKD (follow as your doc: …/docs/chat/v3/javascript/guides/group-channel)
    Thanks for your advice!

Hey @sonkim,

Welcome to the Sendbird Community. Could you DM me your APP_ID?

Also, is this via the Platform API or an SDK?

1 Like

hi Tyler, glad to get your response , we’re using this app iD
<REMOVED>. Could you help us to check?
thanks anyway

Hello @thi_ledinh, are you experiencing the same issue as above? Can you tell me if you’re getting it back from Platform API or SDK?

yes, I got that error when I intergrate with SDK,

I’m using react-native-image-picker to pick video. which is mov file

Can you share with me your render method for the message that contains a file? Which URL are you using? Additionally, can you tell me what version of the JavaScript SDK you’re utilizing?

hi @Tyler ,

I updated my question. Pls take a look again
When update successfully, the response return the success data and I only receive plainUrl like this: “plainUrl”:“https://file-ap-2.sendbird.com/3e81783a29ef4f1c956862e9061fe827.mov”
So you can open/play the url to check

Thanks

Hi,
is there @Tyler or Tyler-bot? Pls help me for quick response

Help me !

I’m a real person. Give me some time to look into this.

1 Like

I took a quick look at this. If file encryption is enabled, you can not obtain the authenticated URL from the Platform API. It has to be obtained from the SDK.

In the SDK, the response you get contains a url key on the message object. This url contains the authenticated URL that you need to view the encrypted file.

Here is an object that was returned to me via the Javascript SDK for a message I uploaded:

appleCriticalAlertOptions: null
channelType: "group"
channelUrl: "sendbird_group_channel_121162250_b6dc718be183b67c8bbef9f37cf11186559c5ae6"
createdAt: 1620751293833
customType: ""
data: ""
errorCode: 0
isOperatorMessage: false
mentionType: "users"
mentionedUsers: []
messageId: 6734857808
messageSurvivalSeconds: -1
messageType: "file"
metaArrays: []
name: "Petrify 2021-05-05 at 10.22.43.png"
ogMetaData: null
parentMessageId: 0
parentMessageText: null
plainUrl: "https://file-us-3.sendbird.com/eb1483404c52411e9f67cb38b1392756.png"
reactions: []
reqId: ""
requestState: "succeeded"
requestedMentionUserIds: []
requireAuth: true
sendingStatus: "succeeded"
silent: false
size: 378872
threadInfo: n {replyCount: 0, mostRepliedUsers: Array(0), lastRepliedAt: 0, updatedAt: 0}
thumbnails: []
type: "image/png"
updatedAt: 0
_sender: n {nickname: "iosTest01", plainProfileUrl: "https://file-us-3.sendbird.com/profile_images/6f67714f145340c48fb5364e32882c2b.jpg", userId: "iosTest01", connectionStatus: "nonavailable", lastSeenAt: 0, …}
metaArray: (...)
sender: (...)
url: "https://file-us-3.sendbird.com/eb1483404c52411e9f67cb38b1392756.png?auth=3r5hcdbxMDJZ3uUfsr-TtHwAgnA2kZS_83gzZrRq4xAsljpAXG2eQBetiTcK-k2F-RngfNrRd6WAevjJBp_W3Q"

something wrong here, above is mov not png :((

I don’t think the file type is super relevant here however, here is an example of the response I get when uploading a .mov. This response comes from the Javascript SDK when I query messages for a channel.

appleCriticalAlertOptions: null
channelType: "group"
channelUrl: "sendbird_group_channel_121162250_b6dc718be183b67c8bbef9f37cf11186559c5ae6"
createdAt: 1620755024441
customType: ""
data: ""
errorCode: 0
isOperatorMessage: false
mentionType: "users"
mentionedUsers: []
messageId: 6734889009
messageSurvivalSeconds: -1
messageType: "file"
metaArrays: []
name: "WorkingExample.mov"
ogMetaData: null
parentMessageId: 0
parentMessageText: null
plainUrl: "https://file-us-3.sendbird.com/46a24c9a1bcd483f83d382d14a8ee71b.mov"
reactions: []
reqId: ""
requestState: "succeeded"
requestedMentionUserIds: []
requireAuth: true
sendingStatus: "succeeded"
silent: false
size: 12769747
threadInfo: n {replyCount: 0, mostRepliedUsers: Array(0), lastRepliedAt: 0, updatedAt: 0}
thumbnails: []
type: "video/quicktime"
updatedAt: 0
_sender: n {nickname: "iosTest01", plainProfileUrl: "https://file-us-3.sendbird.com/profile_images/6f67714f145340c48fb5364e32882c2b.jpg", userId: "iosTest01", connectionStatus: "nonavailable", lastSeenAt: 0, …}
metaArray: (...)
sender: (...)
url: "https://file-us-3.sendbird.com/46a24c9a1bcd483f83d382d14a8ee71b.mov?auth=3r5hcdbxMDJZ3uUfsr-TtHwAgnA2kZS_83gzZrRq4xCxJWGMyUtbQdQR2UmpJdx9Yo91lGBnDaDn1o6TxEIW_g"
1 Like