2

Sending http requests to the /tracks/{id} endpoint from any of our AWS boxes, both inside of different VPCs or from EC2 Classic return 403 status codes, however the same http requests sent from local machines return 200 requested data. This happens both using python's requests library and curl.

edit:

Tested using Google Compute Engine and Digital Ocean and both display same bad behaviour.

using ?ids url parameter I am able curl /tracks?ids=[bad_id]

i.e.
doesn't work: curl https://api.soundcloud.com/tracks/182343690?client_id=XXX
works: curl https://api.soundcloud.com/tracks/?client_id=XXX&ids=182343690

note: Neither work inside requests

The following does however work

import subprocess
subprocess.Popen("curl https://api.soundcloud.com/tracks/?client_id=XXX&ids=182343690", shell=True, stdout=subprocess.PIPE).stdout.read()
Kamran
  • 3,397
  • 26
  • 40
  • Something I noticed is that a head request `curl -I` tends to always work. See my issue here: http://stackoverflow.com/a/36259753/2248638 – skensell Mar 28 '16 at 10:07
  • Also, this seems to be the same issue: http://stackoverflow.com/questions/34879513/soundcloud-403-error-for-a-range-of-ips – skensell Mar 28 '16 at 10:08

1 Answers1

0

I don't know if it's related, but I had some issues with tokens and curl using PHP.

In the end I added the SSL options to my curl request and that solved my issue.

Code snippet

try {
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  ...
  curl_setopt($ch, CURLOPT_VERBOSE, 1);
  $info = curl_getinfo($ch);
  $response = curl_exec($ch);
  $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
  $header = substr($response, 0, $header_size);
  $body = substr($response, $header_size);      
  $result = $body;
  ...
  curl_close($ch);
} catch(Exception  $e) {
  $this->writeLog('authToken() Error Message: ' .$e->getMessage());
}
SteveE
  • 168
  • 1
  • 6