Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
315 views
in Technique[技术] by (71.8m points)

javascript - Could not authenticate you - twitter api v1.1

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

packages i use :

node-fetch

deepmerge - to merge the given options

oauth-1.0a

crypto

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

some important functions and related : https://hastebin.com/eyepikidax.kotlin

the code affected : https://hastebin.com/inehomodag.js

tweet function : (the working function) : https://hastebin.com/xatebakahe.properties

even though the tweet works with the same function _makeRequest(custom function) uploadmedia dont uploadmedia is same as tweet but with extra steps like uploading media

i logged the headers provided by _makeRequest for the tweet function and the upload function

headers: https://hastebin.com/xojotupine.rust

it seems in the uploadmedia function the headers became invalid but in the tweet function they are valid

question from:https://stackoverflow.com/questions/65642758/could-not-authenticate-you-twitter-api-v1-1

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I created a post function so it will create new headers everytime I use it. The issue seems to be because I didn't pass the correct details to the authorize function.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...