I’m at my wit’s end. I have tried everything I can think of for days — my app ID and secret Are correct, my token and token secret are correct, and I’ve inherited Nodejs code that uses Axios to post. Log in routine works fine — I end up at the authorization site and grant access. But when I try to post, I get:
x
hr.js:166 POST https://dev.d1yqqr9z8c2mnj.amplifyapp.com/postTweet 403
(anonymous) @ xhr.js:166
e.exports @ xhr.js:16
e.exports @ dispatchRequest.js:48
Promise.then (async)
u.request @ Axios.js:56
u.<computed> @ Axios.js:80
(anonymous) @ bind.js:11
onSubmit @ PostToTwitter.js:50
(anonymous) @ react-dom.production.min.js:81
_ @ react-dom.production.min.js:101
(anonymous) @ react-dom.production.min.js:105
C @ react-dom.production.min.js:125
I @ react-dom.production.min.js:154
k @ react-dom.production.min.js:143
x @ react-dom.production.min.js:167
yn @ react-dom.production.min.js:1622
ue @ react-dom.production.min.js:7171
En @ react-dom.production.min.js:1687
Cn @ react-dom.production.min.js:1727
Sn @ react-dom.production.min.js:1699
t.unstable_runWithPriority @ scheduler.production.min.js:266
ji @ react-dom.production.min.js:2739
uu @ react-dom.production.min.js:5314
(anonymous) @ react-dom.production.min.js:1656
createError.js:17 Uncaught (in promise) Error: Request failed with status code 403
at e.exports (createError.js:17)
at e.exports (settle.js:19)
at XMLHttpRequest.h.onreadystatechange (xhr.js:60)
my postToTwitter axios code chunk is here:
axios.post(process.env.REACT_APP_API_URL+"/"+this.props.action, {'status': this.props.message,'token':this.props.globalState.user.twitter.token,'secret':this.props.globalState.user.twitter.secret}, config )
.then(res => {
console.log(res);
console.log(res.data);
this.props.callback();
this.setState({isLoading : false});
});
To forestall These questions: there are no typos with the values being sent and yes, I already tested them in the console.
Any idea what I’m doing wrong? Does it have something to do with use of the AWS amplify servers? (Not the cli or api, just how I’m deploying the build)
Thanks!
Things i’d check:
When you say you tested them in the console, meaning you tested the POST request and successfully created a tweet on your local machine or on the remote server?
What was the exact response from Twitter? 403 is the error code but that could be a few things: Documentation Home | Docs | Twitter Developer Platform
Is the application: https://developer.twitter.com/en/apps definitely with Write permissions, and has the token been reset? (tokens keep their permissions so if you created a token, then changed permissions, the old permissions will still apply until you revoke and recreate the token.)
The AWS servers: do they have correct and in sync time / date? This affects OAuth. Can you make a different call like a Favourite or a retweet or some other Write? Does this succeed or also fail?
Can you tweet normally with the account in a browser? Is your account allowed to tweet or did you hit a rate limit or trying to tweet a bad URL?
What’s the exact text of the tweet you’re trying to post? could it be a bug in the libraries that misses or incorrectly encodes a character? i’ve seen that happen before with unicode bullet points.
I’m not familiar with Axios or how it makes HTTP calls but OAuth is very specific about things like sorting parameters, % encoding etc. This is the source of a lot of 403 errors. One way to check is to try an alternative Write call like a “Like” or Retweet.
Yes, I can tweet and my app has write permissions. All the information I get from the 403 is that the server responded with it, and this:
‘’’
403 ERROR
The request could not be satisfied.
What I don’t get it, if AWS is the problem, why can I log into twitter using this setup but not post to it?
"The request could not be satisfied." is not a Twitter error code or response as far as i can tell - this is some other error that’s not the API - but it could be caused by an API error - so you’d have to dig into the library and see if you can get the actual response code and error message from the Twitter API - it would be one of these, under “Error Codes” Documentation Home | Docs | Twitter Developer Platform
Hard to say why exactly without knowing the error the API gives you - but sometimes it’s a rate limit issue - you may simply be tweeting too much, or your app has hit the app level tweet limit of 300 tweets in 3 hours. Are you able to Retweet?
1 Like
Nope. I almost never tweet and have not yet tweeted once with this app. The error message that I pasted is all the feedback I’m getting from anywhere.
Okay, sorry. I deployed my site on Firebase instead of AWS amplify, and the 403 is completely gone. So clearly the issue is that AWS amplify blocks posts from twitter for some unknown reason. I really liked their pipeline with GitHub so this is kind of a shame. I wonder if anyone has experience with dealing with them with this. I’m not even using their back end api, I’m just hosting my site there. Sigh.
1 Like
system
Closed
#8
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.