I'm trying to use the Spotify Web API to search for songs through node, but it keeps sending me a status 400 error with the message: "Only valid bearer authentication supported". This is my code:
app.get("/", (req, res) => {
let searchurl = "https://api.spotify.com/v1/search?";
request.post(
{
url: searchurl,
data: {
q: "john",
type: "album",
},
headers: {
"Content-Type": "application/json",
Authorization:
"Basic " +
Buffer.from(client_id + ":" + client_secret).toString("base64"),
},
method: "POST",
},
function (e, r, body) {
console.log(body);
}
);
});
I don't understand what the issue is and have read through everything I could find, but got nowhere. Am I supposed to use a different access key?
Have a look at the Authorisation Guide for Spotify, you can use the Client Id and Client Secret to get an Access Token and it is that you send as part of an Authorization header when making the request to the Search for an Item endpoint you're trying to use