I am trying to use the Twitter API to tweet, retweet, and upload images, while tweet works as intended, upload media don't work. more information below
the error appears at all the fetch request related to this function
Error:
{ errors: [ { code: 32, message: 'Could not authenticate you.' } ] }
I know whats the error is about, just asking this as I am confused why this would appear only in this function, as the auth info is correct and the same function used to create the headers work in another function
Code was removed since the code did not have anything to do with the error
Read my answer for more info.
The issue was with the authorization headers, I had to generate them for each request.It was easy as creating a wrapper function that will take the request details (the needed ones) and output the headers
I have a Twitter API library written in typescript (unmaintained for now :/ ) That uses this, don't suggest completely using that, just take what you need from it
^^ Above Links to - https://github.com/typicalninja493/tweets.ts/blob/master/src/rest/bucket.ts#L200