ERROR (node:7) [DEP0005] DeprecationWarning: Buffer() when using clientCredentialsGrant
ghitafilali opened this issue · comments
I am trying to query the spotifyAPI from an AWS Lambda function and I get an error that prevents me from doing so because of the use of Buffer() in the function clientCredentialsGrant:
ERROR (node:7) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
This is the code that I use to do so (it is for the most part inspired from your examples):
var spotifyAPI = new SpotifyWebApi({
clientId: "clientId",
clientSecret: "clientSecret",
});
spotifyAPI.clientCredentialsGrant().then(
function (data: any) {
console.log('The access token expires in ' + data.body['expires_in']);
console.log('The access token is ' + data.body['access_token']);
// Save the access token so that it's used in future calls
spotifyAPI.setAccessToken(data.body['access_token']);
},
function (err: any) {
console.log('Something went wrong when retrieving an access token', err);
}
);
Could you please help me fix this issue?
This is an issue that I had with the node spotify web api not with this library