简体   繁体   中英

Get artist from spotify api using ClientID

I was using spotify api to get info about a artist with the code below:

spotify_artist = requests.get('https://api.spotify.com/v1/search?q=U2"&type=artist").json()
print(spotify_artist['artists']['items'][0]['genres'])

But I get:

{
  "error": {
    "status": 401,
    "message": "No token provided"
  }
}

So I get a spotify clientID but when I use it its not working:

https://api.spotify.com/v1/search?q=U2%22&type=artist&ClientID=key

(key is the ClientID of the spotify)

But I get the same error:

{
  "error": {
    "status": 401,
    "message": "No token provided"
  }
}

Do you know why?

I generate a key (cliente id) for the example you can see that dont works properly:

https://api.spotify.com/v1/search?q=U2&type=artist&client_id=38a48a7baeae43b8a74a52fc25a85cd0

The client id should be sent using client_id variable

Spotify Web API Authorization Guide

According to spotify developer news you can't do a call to api without authentication.

YOu need to use requests to authenticat first.

If you just want to do one-off / ad-hoc request to Spotify API, you can use https://developer.spotify.com/console/ . There you can choose which API to call and just fill in the fields needed (including OAuth Token, where they have Get Token button to guide you).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM