lastfm-node icon indicating copy to clipboard operation
lastfm-node copied to clipboard

Error code 14 after receiving a new token

Open joey-kwl opened this issue 4 years ago • 1 comments

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);
        }
    }
});

joey-kwl avatar Jun 24 '20 13:06 joey-kwl

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

gil avatar Aug 31 '23 22:08 gil