<?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 Re: INVALID_CLIENT: Invalid redirect URI in Spotify for Developers</title>
    <link>https://community.spotify.com/t5/Spotify-for-Developers/INVALID-CLIENT-Invalid-redirect-URI/m-p/5964285#M13254</link>
    <description>&lt;P&gt;&lt;A href="https://stackoverflow.com/a/75292843/7111585" target="_blank" rel="noopener"&gt;At this page&lt;/A&gt; is working code and instructions.&lt;/P&gt;</description>
    <pubDate>Sun, 24 Mar 2024 09:28:24 GMT</pubDate>
    <dc:creator>Ximzend</dc:creator>
    <dc:date>2024-03-24T09:28:24Z</dc:date>
    <item>
      <title>INVALID_CLIENT: Invalid redirect URI</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/INVALID-CLIENT-Invalid-redirect-URI/m-p/5964134#M13253</link>
      <description>&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;const REDIRECT_URI = 'http://localhost:3000/callback';
const SCOPES = 'user-library-read user-read-playback-position';

// Redirect to Spotify authorization page
app.get('/login', (req, res) =&amp;gt; {
const queryParams = querystring.stringify({
response_type: 'code',
client_id: CLIENT_ID,
redirect_uri: REDIRECT_URI,
scope: SCOPES,
});
res.redirect(`https://accounts.spotify.com/authorize?${queryParams}`);
});

// Callback route after user authorization
app.get('/callback', async (req, res) =&amp;gt; {
const { code } = req.query;

try {
// Exchange authorization code for access token
const response = await axios.post('https://accounts.spotify.com/api/token', {
grant_type: 'authorization_code',
code,
redirect_uri: REDIRECT_URI,
client_id: CLIENT_ID,
client_secret: CLIENT_SECRET,
});

const accessToken = response.data.access_token;
// You can now use accessToken to make requests to the Spotify API on behalf of the user

res.send('Authorization successful! You can now make requests to the Spotify API.');
} catch (error) {
console.error('Error exchanging authorization code for access token:', error);
res.status(500).send('Error exchanging authorization code for access token');
}
});&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;</description>
      <pubDate>Sun, 24 Mar 2024 07:15:53 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/INVALID-CLIENT-Invalid-redirect-URI/m-p/5964134#M13253</guid>
      <dc:creator>chahatjain</dc:creator>
      <dc:date>2024-03-24T07:15:53Z</dc:date>
    </item>
    <item>
      <title>Re: INVALID_CLIENT: Invalid redirect URI</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/INVALID-CLIENT-Invalid-redirect-URI/m-p/5964285#M13254</link>
      <description>&lt;P&gt;&lt;A href="https://stackoverflow.com/a/75292843/7111585" target="_blank" rel="noopener"&gt;At this page&lt;/A&gt; is working code and instructions.&lt;/P&gt;</description>
      <pubDate>Sun, 24 Mar 2024 09:28:24 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/INVALID-CLIENT-Invalid-redirect-URI/m-p/5964285#M13254</guid>
      <dc:creator>Ximzend</dc:creator>
      <dc:date>2024-03-24T09:28:24Z</dc:date>
    </item>
  </channel>
</rss>

