New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

spotifylib.js

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

spotifylib.js

Spotify API

unpublished
latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source
NPM Install Info

NPM Version NPM Downloads License

spotifylib.js

node.js lib based on Spotify's web api - covering all you will need. Easily fetching data about: tracks, albums, artists and even able to pause, resume and start different playbacks.

Authorization

First thing to do when authorizating your spotify app you need to use get your code which will later be used to request an access token. Using #generate you are able to concat a callback uri to obtain your Spotify code. Example seen here

const express = require('express');
const app = express();

const { SpotifyClient } = require('spotifylib.js');
const client = new SpotifyClient({
	client_id: 'CLIENT ID',
	client_secret: 'CLIENT SECRET',
	redirect_uri: 'http://localhost:3000/callback' // The redirect uri
});

app.get('/login', (req,  res) => {
	let uri = client.authorization.generate();
	res.redirect(uri);
});

After this you will need to exchange the code for a access token using #exchange(code) - these tokens expire every hour which means you get a refresh token along with it, which is used to refresh the token every expiry.

app.get('/callback', async (req, res) => {
	let code = req.query.code;
	let tokens =  await client.authorization.exchange(code);
	res.send(tokens);
});

Once the refresh token is obtained it must be put into the SpotifyClient options when initiated as refresh_token then you can start requesting data from Spotify's web api.

View the documenation here for more info.

Keywords

spotify

FAQs

Package last updated on 17 Feb 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts