1

I've got my soundcloud api ID but when I'm trying to log in with the user credentials(client id, secret, username,password) in python3 I get this:

401 Client Error: Unauthorized for url: https://api.soundcloud.com/oauth2/token

The only thing I'm doing in the code is this:

client = soundcloud.Client(client_id='YOUR_CLIENT_ID',
                       client_secret='YOUR_CLIENT_SECRET',
                       username='YOUR_USERNAME',
                       password='YOUR_PASSWORD')

What might be the problem? I didn't put any redirect uri in the registeration process of my app as I knew I was going to do the credentials authentication so might that be the problem? I really can't figure out what is going wrong here because that's straight from their API website!

Biffen
  • 6,249
  • 6
  • 28
  • 36
bnc
  • 57
  • 2
  • 14

2 Answers2

1

Solution:

Instead using the above method I used request module

http://docs.python-requests.org/en/latest/user/quickstart/#redirection-and-history

and did a Post to:

https://api.soundcloud.com/oauth2/token

using these parameters:

grant_type=password&client_id=YOUR_CLIENT_ID&client_secret=YOUR_SECRET_ID&username=USERNAME&password=PASSWORD&scope=non-expiring

This answer was found from here:

Soundcloud API authentication without a web browser

bnc
  • 57
  • 2
  • 14
0

Yesterday we're having the same issue, but with Javascript client. We realised that our app was performing a GET request to the SoundCloud API. I took a look in the request params to see what we're sending, then I could get the client_id that our app was sending to SoundCloud.

So I did the login and went to "registered apps" (https://soundcloud.com/you/apps) on SoundCloud manage panel. I got the client_id that SoundCloud was showing to me in one of the apps we have registered, I made some tests and put it in the app. Now it works fine.

I'm not sure why this client_id had changed.

user229044
  • 232,980
  • 40
  • 330
  • 338
ebragaparah
  • 305
  • 4
  • 7
  • Thanks for answer! I got mine working by using this solution: https://stackoverflow.com/questions/14449508/soundcloud-api-authentication-without-a-web-browser?noredirect=1&lq=1 I'm not sure what is the issue with soundcloud examples. So I used the requests module ( http://docs.python-requests.org/en/latest/user/quickstart/#redirection-and-history ) and did the POST with the credentials as parameters and was able to recieve a token. – bnc Jan 25 '18 at 10:46