App posting status update gets 403 errors, only with media_ids


#1

Hi

I have just built a web app through which users can post status updates. This uses the oauth.io service and their javascript client.

It can post status updates, ok. The problem is when including media_ids the response is 403, “Could not authenticate you.” … which is clearly false but I guess it is a general case including spam detection etc (?).

To be clear, the actual post to the media upload endpoint is successful. It is the subsequent status update post that fails, if it includes media_ids.

I did manage to post just one status update with media_ids (one image) but, strangely, that image now 24 hours later has disappeared! I’m pretty sure it was attached to this tweet https://twitter.com/cppn_x/status/803591121049882626 or it might have been another one around that time if the whole tweet has disappeared.

Here is an example of a failure.

Request URL:https://oauth.io/request/twitter/%2F1.1%2Fstatuses%2Fupdate.json
Request Method:POST
Remote Address:52.205.96.147:443

Request Headers

POST /request/twitter/%2F1.1%2Fstatuses%2Fupdate.json HTTP/1.1
Host: oauth.io
Connection: keep-alive
Content-Length: 68
Accept: */*
oauthio: k=G8cnIzClY3nbnOniOAQzkHvMcfE&oauthv=1&oauth_token=***********&oauth_token_secret=************
Origin: https://floybix.github.io
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.98 Safari/537.36
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Referer: https://floybix.github.io/cppnx/?cppn=%7Binputs_%23%7By_d_x_bias%7D_nodes_%7Bi0_g_n25_g_n108_S%7D_edges_%7Bi0_%7Bd_0.5334715_bias_0.2856047%7D_h_%7Bi0_-0.5621044_bias_1.3851554_n108_0.6060991_d_-4.3400005_n25_-4.7273282%7D_s_%7Bx_3.3283347_i0_2.5512835_y_4.480216_n25_0.8892112%7D_v_%7Bn108_2.8319026_n25_-0.1112539_bias_1.4480412%7D_n25_%7Bi0_-2.5059539%7D_n108_%7Bi0_1.8577244%7D%7D%7D
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.8

Form Data

status=glass+in+sunlight+%23cppnx&media_ids%5B%5D=803965075908390912

Response

Status Code:401 Unauthorized

{"errors":[{"code":32,"message":"Could not authenticate you."}]}

One second earlier… the media upload

Request URL:https://oauth.io/request/twitter/https%3A%2F%2Fupload.twitter.com%2F1.1%2Fmedia%2Fupload.json
Request Method:POST
Status Code:200 OK
{"media_id":803965075908390912,"media_id_string":"803965075908390912","size":234473,"expires_after_secs":86400,"image":{"image_type":"image\/png","w":600,"h":600}}

#2

Pretty odd - I can still see that media ID does exist and has not yet expired. Are you able to attach it to a Tweet sent using the same credentials, via any other tool (e.g. twurl)?

You seem to be specifying media_ids[]=803965075908390912 which I’m not sure is valid either - try dropping the square brackets?

Something else worth looking at is that you’re not specifying a media_category on upload (which should be tweet_image in this case).


#3

Many thanks for your reply. Indeed, the problem was the brackets on media_ids. That is automatically added by Javascript’s FormData when the data is given as an array. I used an array because the endpoint specifies “A list of media_ids…” - perhaps it should say “a comma-separated list” or something.

Btw, on your other point, the simple media upload does not list media_category as a parameter.

In case you can pass on feedback, it would be nice if the response error was less misleading than “Could not authenticate you.” Also, it would be great if the API doc page could include an example of media_ids.

Anyway, all is well now. Cheers.


#4

Great feedback. I’m glad this is resolved for you! I can definitely take those suggestions on board, and in particular able to update the docs, so I’ll see what we can do there.


#5