Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
scopes : ['playlist-modify-public', 'playlist-modify-private'],
redirectPath : '/spotify-auth',
port : 8085
};
const clientId = process.env.DJ_LAZY_CLIENT_ID;
const clientSecret = process.env.DJ_LAZY_CLIENT_SECRET;
const redirectUri = `http://localhost:${config.port}${config.redirectPath}`;
if (!clientId || !clientSecret) {
const err = new Error('Missing cliendId or clientSecret\nEnsure you have DJ_LAZY_CLIENT_ID and DJ_LAZY_CLIENT_SECRET set as ENV variables');
throw err;
}
// Create Spotify API wrapper
const spotifyApi = new SpotifyWebApi({clientId, clientSecret, redirectUri});
// Create the authorization URL
const authorizeURL = spotifyApi.createAuthorizeURL(config.scopes, 'mystate');
const app = express();
let server;
app.get(config.redirectPath, (req, res) => {
const authToken = req.query.code;
res.send('');
server.close();
startScraping(authToken);
});
server = app.listen(config.port, _ => console.log(`Server listening on port ${config.port}!\n`) );
open(authorizeURL);
import { parse } from 'url';
import SpotifyWebApi from 'spotify-web-api-node';
import urlMatch from './url';
const spotify = new SpotifyWebApi({
clientId: process.env.SPOTIFY_CLIENT_ID,
clientSecret: process.env.SPOTIFY_CLIENT_SECRET,
redirectUri: 'https://combine.fm',
});
function exactMatch(needle, haystack, type) {
// try to find exact match
return haystack.find((entry) => {
if (entry.type !== type) {
return false;
}
if (entry.name === needle) {
return entry;
}
try {
const err: string[] = [];
if (this.clientId.trim().length === 0) {
err.push('clientId');
}
if (this.clientSecret.trim().length === 0) {
err.push('clientSecret');
}
if (this.redirectURI.trim().length === 0) {
err.push('redirectURI');
}
if (err.length > 0) {
throw new Error(err.join(', ') + ' missing');
}
this.client = new SpotifyWebApi({
clientId: this.clientId,
clientSecret: this.clientSecret,
redirectUri: this.redirectURI,
});
if (this._accessToken && this._refreshToken) {
this.client.setAccessToken(this._accessToken);
this.client.setRefreshToken(this._refreshToken);
this.retry.IRefreshToken = 0;
}
try {
if (opts.token && !_.isNil(this.client)) {
this.client.authorizationCodeGrant(opts.token)
.then((data) => {
this.authenticatedScopes = data.body.scope.split(' ');
import SpotifyWebApi from 'spotify-web-api-node';
import * as R from 'ramda';
import fetch from 'node-fetch';
import dotenv from 'dotenv';
dotenv.config();
const DEV_HOST = 'http://localhost:3000';
const SCOPES_STR =
'user-library-read playlist-read-private playlist-read-collaborative playlist-modif' +
'y-public playlist-modify-private user-library-read ugc-image-upload user-top-read';
const SCOPE_LIST = SCOPES_STR.split(' ');
const SPOTIFY_API_URL = 'https://api.spotify.com/v1';
const spotifyApi = new SpotifyWebApi({
clientId: process.env.SPOTIFY_CLIENT,
clientSecret: process.env.SPOTIFY_CLIENT_SECRET,
redirectUri: process.env.SPOTIFY_REDIRECT_URI
});
const { APP_CLIENT_URL } = process.env;
const INTERVAL_PERIOD = 5000;
let userMap = {};
const setUpTokens = (accessToken, refreshToken) => {
spotifyApi.setAccessToken(accessToken);
spotifyApi.setRefreshToken(refreshToken);
};
export const setUserAndTokens = (userId, accessToken, refreshToken) => {
userMap[userId] = {
const loadBrianfy = async (access, refresh) => {
const Brianfy = new SpotifyWebApi()
Brianfy.setAccessToken(access)
Brianfy.setRefreshToken(refresh)
return Brianfy
}
constructor() {
super();
this.spotifyClient = new SpotifyAPIClient({
clientId: config.spotify.clientId,
clientSecret: config.spotify.clientSecret,
redirectUri: config.spotify.redirectUri,
});
this.scopes = config.spotify.scopes;
}
import SpotifyWebApi from 'spotify-web-api-node';
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import configureStore from './stores/configureStore';
import Root from './components/Root';
import App from './components/App';
import * as AUTH from './constants/auth';
const isDevelopmentEnv = (process.env.NODE_ENV !== 'production')
window.spotifyApi = new SpotifyWebApi({
clientId: isDevelopmentEnv ? AUTH.CLIENT_ID_DEV : AUTH.CLIENT_ID_PROD,
redirectUri: isDevelopmentEnv ? AUTH.REDIRECT_URI_DEV : AUTH.REDIRECT_URI_PROD
})
const store = configureStore()
ReactDOM.render(
,
document.getElementById('app')
)