lastfm-node
lastfm-node copied to clipboard
Error code 14 after receiving a new token
Not sure if I did it right, but I get my token (which does work) after that I tried to update my scrobble and I get Error 14, "Unauthorized token".
lastfm.request("auth.gettoken", {
handlers: {
success: function(data) {
let token = data.token;
let track = {
artist: "TWICE",
track: "TT",
timestamp: + new Date()
}
var sessions = lastfm.session({
token: token,
handlers: {
success: function(session) {
console.log(session)
lastfm.update('nowplaying', session, { track: track } );
lastfm.update('scrobble', session, { track: track, timestamp: + new Date() });
},
error: function(track, err) {
console.log(track, err)
},
retrying: (retry) => {
console.log(retry)
}
}
});
},
error: function(error) {
console.log("Error: " + error.message);
}
}
});
After you get the token, you need to open this page on the user's browser:
http://www.last.fm/api/auth/?api_key=${apiKey}&token=${token}
You can make .update()
calls only after it's authorized. You can read more about it here: https://www.last.fm/api/desktopauth