rinukkusu / spotify-dart

A dart library for interfacing with the Spotify API.
BSD 3-Clause "New" or "Revised" License
207 stars 93 forks source link

Get cover art image from track #132

Closed Klairm closed 1 year ago

Klairm commented 2 years ago

Hey, I've seen that the only option I have to get the cover art would be using href prop in the track, but when I try to open the link it gives it returns me this: imagen

Do I need a token for a simple thing like getting a track cover art?

gutala commented 2 years ago

Yes, you have to authorize. But the Client Credentials Flow is enough for this case https://github.com/rinukkusu/spotify-dart#client-credentials-flow

Klairm commented 2 years ago

Yes, you have to authorize. But the Client Credentials Flow is enough for this case https://github.com/rinukkusu/spotify-dart#client-credentials-flow

I see, but how would I use those instances to pass a token in the GET request?

Like, in official spotify docs they return the images in the GET request for tracks https://developer.spotify.com/documentation/web-api/reference/#/operations/get-track

The problem is that spotify-dart doesn't returns the images, and I should use the href sending a token to get it instead

gutala commented 2 years ago

Hm not sure if I understood you correctly. The example you have in your screenshot is returning me the images in the response.

grafik

But like mentioned before, you have to provide the token for the GET request. This doesnt work with the basic GET request from the browser. I used Postman in the screenshot, but the library here is taking care of this Authorization handling also.

Klairm commented 2 years ago

Hm not sure if I understood you correctly. The example you have in your screenshot is returning me the images in the response.

grafik

But like mentioned before, you have to provide the token for the GET request. This doesnt work with the basic GET request from the browser. I used Postman in the screenshot, but the library here is taking care of this Authorization handling also.

Yes, i tried with curl providing a token, but the thing is, shouldn't I be able to do it without token? just with the normal credentials?

Klairm commented 2 years ago

Any ideas?

rinukkusu commented 1 year ago

Well, to use the API and get information about a track you need to provide some sort of authentication. This works with a token you receive from the authorization flow where you authorize your App to login, but also with the generated token pair from your Spotify Developer page.

To access the album/track images you need to use the CDN urls from the images array, not the one from the href property. These CDN urls also do NOT need authentication:

grafik