Good afternoon,
So I've been following this tutorial in working toward setting up our app to support attaching images to... whatever the latest incarnation of your chatlike API is called (a collection of functions under the "ConversationsApi" grouping, neither chat nor web messaging I think... it's all "chat" to us internally ). Whatever that catty API is called, so far everything seems to be working well... except that the tutorial assumes you've been implementing all the underlying API calls yourself. In this way, it appears to be a tad... "incomplete", for lack of a better word.
So I've gotten through step 1; short version:
// Where conversations = an instance of PlatformClientWHateverItIs.ConversationsApi();
var info = await conversations.getConversation(conversationID);
// According to the tutorial, the "communication ID" is the agent's first message's ID.
// getParticipantByPurpose is a function we wrote, because a lot of Genesys things
// require random bits and pieces from the "participants" sub-object. It returns
// info.participants, the one with purpose=second parameter ("agent" in this instance).
var agent = getParticipantByPurpose(info.participants, "agent");
// And, as the tutorial showed, that sub-sub-object has an array called messages,
// and that array is not empty, and the first item in the array is an object with an "id".
// So everything is working well at this point.
var communicationID = agent.messages[0].id;
// Now comes the second request, to get the upload URL and an ID we can use in chat/messages
var media = await conversations.postConversationsMessageCommunicationMessagesMedia(conversationID, communicationID);
// This succeeds as well, returning an object with an ID and upload URL (and other stuff)
Next, the tutorial wants you to send the file to the upload URL... and there is no way to accomplish this using the SDK. Normally this would be a non-issue - I could do XHRs in my sleep, and the Fetch API makes it even a bit easier (since it supports await
and all that vs. the usual callback-mania that is JS ). Buuuuuut..... "The request headers should include the Authorization header with the same bearer token that is used to make other API requests." Wellllllll........ohhhhh.....kay? So here we are.
So what I need to do is discover how to calculate the "bearer" header for the raw fetch
call. Now when the app starts, the access token is currently in a place where users can't find it, though I suppose I could leave it somewhere for this part of the code to reference (though that sounds a bit risky)... but even then, isn't "bearer" some hash or something? I can see it in the Network tab, but idk whether it's using something simple like base-64, or a one-way hashing algorithm like PHP's password_hash, or something more suited for transferring data like RSA or whatever... also if I remember like 2 years ago when I read up on the OAuth stuff I guess it wasn't just a hash of the access token... yeah, an SDK endpoint for this would have been super helpful... or am I just missing something, again? That is most likely the case, I'm sure.
Thanks in advance.