Client error 403: Forbidden when trying to delete / update sets using SoundCloud python API

I am developing a python application for managing playlists (sets). This application should create / update / delete sets using the SoundCloud API.

It’s good to create a set using the API. But when I try to change or delete the created playlists, Im gets 403 Client Error: Forbidden.

I used “SoundCloud Connect Screenless Authentication” from the API documentation.

Here is my code:

client = soundcloud.Client(client_id='MY_ID', client_secret='MY_SECRET', username='NAME', password='PASS') client.post('/playlists', playlist={'title': 'Test playlist', 'sharing': 'public', 'tracks': [], 'permalink': 'test-playlist'}) client.delete('/playlists/test-playlist') 

And im getting the following exception on removal:

 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python2.7/dist-packages/soundcloud/client.py", line 130, in _request return wrapped_resource(make_request(method, url, kwargs)) File "/usr/local/lib/python2.7/dist-packages/soundcloud/request.py", line 190, in make_request result.raise_for_status() File "/usr/local/lib/python2.7/dist-packages/requests/models.py", line 683, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 403 Client Error: Forbidden 

I also get the same whet exceptions trying to add tracks to the playlist

 client.put('/playlists/test-playlist', playlist={'tracks': tracks}) 

where are the tracks:

 [{'id': 57417403}, {'id': 100249929}, {'id': 37964083}] 
+4
source share

Source: https://habr.com/ru/post/1491981/


All Articles