thelinmichael / spotify-web-api-node

A Node.js wrapper for Spotify's Web API.
http://thelinmichael.github.io/spotify-web-api-node/
MIT License
3.1k stars 499 forks source link

WebapiError: Unauthorized #137

Open pirmax opened 7 years ago

pirmax commented 7 years ago
var SpotifyWebApi = require('spotify-web-api-node');

var spotifyApi = new SpotifyWebApi({
    clientId : '',
    clientSecret : '',
    redirectUri : ''
});

spotifyApi.getTrack('2q8eudK0r9ImgCB1XhFfxG').then(function(data) {
    console.log(data);
});

My code worked but for 1 month I have this error.

(node:12824) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): WebapiError: Unauthorized (node:12824) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

ersel commented 7 years ago

Seems like Spotify now requires authentication on all their endpoints, so search endpoint is no longer public.

https://developer.spotify.com/news-stories/2017/01/27/removing-unauthenticated-calls-to-the-web-api/

I think you should try authorising your client before making the call.

ersel commented 7 years ago

If you don't need to access any user specific information and after the search function solely, you could use the Client Credential Flow as explained in the documentation.

https://github.com/thelinmichael/spotify-web-api-node#client-credential-flow

prashanthr commented 6 years ago

Same problem as #147 ? Check https://github.com/thelinmichael/spotify-web-api-node/issues/147#issuecomment-331735279