<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic spotify-web-api-node authenticate user in Spotify for Developers</title>
    <link>https://community.spotify.com/t5/Spotify-for-Developers/spotify-web-api-node-authenticate-user/m-p/5362805#M4321</link>
    <description>&lt;P&gt;Hey guys, I'm trying to use the library "spotify-web-api-node" the function "getMe"&amp;nbsp; and when I use my token accountant (Spotify developer) it works but when the other accountant doesn't work and returns error 403.&lt;/P&gt;&lt;P&gt;Why happens this problem?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm a novated in requests api&lt;/P&gt;&lt;P&gt;Thank you !!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;class User{
    login(req, res){
        res.redirect(spotifyApi.createAuthorizeURL(scopes));
    };
      
    callback(req, res){
        const error = req.query.error;
        const code = req.query.code;
        const state = req.query.state;
      
        if (error) {
          console.error('Callback Error:', error);
          res.send(`Callback Error: ${error}`);
          return;
        }
      
        spotifyApi
          .authorizationCodeGrant(code)
          .then(data =&amp;gt; {
            const access_token = data.body['access_token'];
            const refresh_token = data.body['refresh_token'];
            const expires_in = data.body['expires_in'];
      
            spotifyApi.setAccessToken(access_token);
            spotifyApi.setRefreshToken(refresh_token);
      
            console.log('access_token:', access_token);
            console.log('refresh_token:', refresh_token);
      
            console.log(
              `Sucessfully retreived access token. Expires in ${expires_in} s.`
            );
            res.send('Success! You can now close the window.');
      
            setInterval(async () =&amp;gt; {
              const data = await spotifyApi.refreshAccessToken();
              const access_token = data.body['access_token'];
      
              console.log('The access token has been refreshed!');
              console.log('access_token:', access_token);
              spotifyApi.setAccessToken(access_token);
            }, expires_in / 2 * 1000);
          })
          .catch(error =&amp;gt; {
            console.error('Error getting Tokens:', error);
            res.send(`Error getting Tokens: ${error}`);
          });
      };

      
   async verifyUser(req, res){
    
    
    //const token = spotifyApi.getAccessToken();
    //res.json(spotifyApi.getAccessToken())
        
   await spotifyApi.getMe()
    .then(function(data) {
      res.json({"Some information about the authenticated user": data.body});
    }, function(err) {
        res.json({'Something went wrong!': err});
    });
     }
}

module.exports = new User();&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 05 Apr 2022 14:03:21 GMT</pubDate>
    <dc:creator>Mathrodri25</dc:creator>
    <dc:date>2022-04-05T14:03:21Z</dc:date>
    <item>
      <title>spotify-web-api-node authenticate user</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/spotify-web-api-node-authenticate-user/m-p/5362805#M4321</link>
      <description>&lt;P&gt;Hey guys, I'm trying to use the library "spotify-web-api-node" the function "getMe"&amp;nbsp; and when I use my token accountant (Spotify developer) it works but when the other accountant doesn't work and returns error 403.&lt;/P&gt;&lt;P&gt;Why happens this problem?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm a novated in requests api&lt;/P&gt;&lt;P&gt;Thank you !!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;class User{
    login(req, res){
        res.redirect(spotifyApi.createAuthorizeURL(scopes));
    };
      
    callback(req, res){
        const error = req.query.error;
        const code = req.query.code;
        const state = req.query.state;
      
        if (error) {
          console.error('Callback Error:', error);
          res.send(`Callback Error: ${error}`);
          return;
        }
      
        spotifyApi
          .authorizationCodeGrant(code)
          .then(data =&amp;gt; {
            const access_token = data.body['access_token'];
            const refresh_token = data.body['refresh_token'];
            const expires_in = data.body['expires_in'];
      
            spotifyApi.setAccessToken(access_token);
            spotifyApi.setRefreshToken(refresh_token);
      
            console.log('access_token:', access_token);
            console.log('refresh_token:', refresh_token);
      
            console.log(
              `Sucessfully retreived access token. Expires in ${expires_in} s.`
            );
            res.send('Success! You can now close the window.');
      
            setInterval(async () =&amp;gt; {
              const data = await spotifyApi.refreshAccessToken();
              const access_token = data.body['access_token'];
      
              console.log('The access token has been refreshed!');
              console.log('access_token:', access_token);
              spotifyApi.setAccessToken(access_token);
            }, expires_in / 2 * 1000);
          })
          .catch(error =&amp;gt; {
            console.error('Error getting Tokens:', error);
            res.send(`Error getting Tokens: ${error}`);
          });
      };

      
   async verifyUser(req, res){
    
    
    //const token = spotifyApi.getAccessToken();
    //res.json(spotifyApi.getAccessToken())
        
   await spotifyApi.getMe()
    .then(function(data) {
      res.json({"Some information about the authenticated user": data.body});
    }, function(err) {
        res.json({'Something went wrong!': err});
    });
     }
}

module.exports = new User();&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Apr 2022 14:03:21 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/spotify-web-api-node-authenticate-user/m-p/5362805#M4321</guid>
      <dc:creator>Mathrodri25</dc:creator>
      <dc:date>2022-04-05T14:03:21Z</dc:date>
    </item>
  </channel>
</rss>

