thelinmichael / spotify-web-api-node

A Node.js wrapper for Spotify's Web API.
http://thelinmichael.github.io/spotify-web-api-node/
MIT License
3.1k stars 499 forks source link

Multi user config #479

Open DJHammers opened 1 year ago

DJHammers commented 1 year ago
let spotifyApi = new SpotifyWebApi();
        spotifyApi
            .authorizationCodeGrant(`auth code`)
            .then(function (data) {
                console.log('Retrieved access token', data.body['access_token']);
                spotifyApi.setAccessToken(data.body['access_token']);
                return spotifyApi.getMe();
            })
            .then(function (data) {
                console.log('Retrieved data for ' + data.body['display_name']);
                console.log('Image URL is ' + data.body.images[0].url);

                console.log('This user has a ' + data.body.product + ' account');
            })
            .catch(function (err) {
                console.log('Something went wrong:', err.message);
            });

am using this on multiuser project so it only use authorizationCodeGrant to fetch user why its giving

Something went wrong: An authentication error occurred while communicating with Spotify's Web API.
Details: invalid_client.

the readme file says client is optional

// credentials are optional
var spotifyApi = new SpotifyWebApi({
  clientId: 'fcecfc72172e4cd267473117a17cbd4d',
  clientSecret: 'a6338157c9bb5ac9c71924cb2940e1a7',
  redirectUri: 'http://www.example.com/callback'
});

but actually they are required how do i fix this

DJHammers commented 1 year ago

i need to log in to bot like spotify-web-api-js npm it only require accesstoken