'INVALID_CLIENT: Invalid redirect URI | I am not sure how to fix this

import os from flask import Flask, request, url_for, session, redirect import spotipy from spotipy.oauth2 import SpotifyOAuth, SpotifyClientCredentials

app = Flask(name)

app.secret_key = "s8dfn39fn923q" app.config['SESSION COOKIE NAME'] = 'Aarons Cookie' TOKEN_INFO = "token_info"

@app.route('/') def login(): sp_oauth = create_spotify_oauth() auth_url = sp_oauth.get_authorize_url() return redirect(auth_url)

@app.route('/redirect') def redirect_page(): sp_oauth = create_spotify_oauth() session.clear() code = request.args.get('code') token_info = sp_oauth.get_access_token(code) session[TOKEN_INFO] = token_info return redirect(url_for('redirect_page', _external=True))

@app.route('/getTracks') def get_tracks(): return 'Best songs of all time'

def create_spotify_oauth(): return SpotifyOAuth( client_id="client", client_secret="secret", redirect_uri=url_for('redirect_page', _external=True), scope="user-top-read")

I tried to redirect the user to the get_tracks page but it does not work I also have installed all the packages that are needed for the program



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source