<?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 Authorization Code Flow: 500 Internal Server Error at initial step of authorization in Spotify for Developers</title>
    <link>https://community.spotify.com/t5/Spotify-for-Developers/Authorization-Code-Flow-500-Internal-Server-Error-at-initial/m-p/5006041#M807</link>
    <description>&lt;P&gt;Let me preface this by saying I am new to working with APIs and making requests.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am running a website with via flask on an AWS EC2 instance with ubuntu 20.04 (not sure if this will help but just to give as much info as possible). So far I have been following the Authorization Code Flow guide on github, but I have been having some trouble.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a snippet of my app.py file for the flask app:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;CLIENT_ID = credentials.clientid
SPOTIFY_AUTH_URL = "https://accounts.spotify.com/authorize"
CLIENT_SIDE_URL = "http://www.drewmi.ch"
PORT = 80
REDIRECT_URI = "{}:{}/redirect".format(CLIENT_SIDE_URL, PORT)
SCOPE = "playlist-modify-private"
STATE = ""

@app.route("/")
def home_function():
    return render_template("home.html")



@app.route("/spotify")
def spotify():
    payload = {
        'client_id': CLIENT_ID,
        'response_type': 'code',
        'redirect_uri': REDIRECT_URI,
        'state' : STATE,
        'scope': SCOPE,
    }

    res = make_response(redirect(f'{SPOTIFY_AUTH_URL}/?{urlencode(payload)}'))
    return res

@app.route("/redirect")
def redirect():
    startup.getUserToken(request.args['code'])
    return render_template("redirect.html")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I navigate to the /spotify page on my website, I don't even make it to the spotify login prompt. I get a 500 Internal Server Error. On the spotify dashboard I have my redirect URI set to "&lt;A href="http://www.drewmi.ch/redirect&amp;quot;," target="_blank"&gt;http://www.drewmi.ch/redirect",&lt;/A&gt;&amp;nbsp;I've found many people have made the mistake there, but I don't think that's the case here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The flow I'm aiming to have is /spotify -&amp;gt; login -&amp;gt; /redirect -&amp;gt; ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Drew&lt;/P&gt;</description>
    <pubDate>Mon, 27 Jul 2020 20:36:55 GMT</pubDate>
    <dc:creator>drew_mich</dc:creator>
    <dc:date>2020-07-27T20:36:55Z</dc:date>
    <item>
      <title>Authorization Code Flow: 500 Internal Server Error at initial step of authorization</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Authorization-Code-Flow-500-Internal-Server-Error-at-initial/m-p/5006041#M807</link>
      <description>&lt;P&gt;Let me preface this by saying I am new to working with APIs and making requests.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am running a website with via flask on an AWS EC2 instance with ubuntu 20.04 (not sure if this will help but just to give as much info as possible). So far I have been following the Authorization Code Flow guide on github, but I have been having some trouble.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a snippet of my app.py file for the flask app:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;CLIENT_ID = credentials.clientid
SPOTIFY_AUTH_URL = "https://accounts.spotify.com/authorize"
CLIENT_SIDE_URL = "http://www.drewmi.ch"
PORT = 80
REDIRECT_URI = "{}:{}/redirect".format(CLIENT_SIDE_URL, PORT)
SCOPE = "playlist-modify-private"
STATE = ""

@app.route("/")
def home_function():
    return render_template("home.html")



@app.route("/spotify")
def spotify():
    payload = {
        'client_id': CLIENT_ID,
        'response_type': 'code',
        'redirect_uri': REDIRECT_URI,
        'state' : STATE,
        'scope': SCOPE,
    }

    res = make_response(redirect(f'{SPOTIFY_AUTH_URL}/?{urlencode(payload)}'))
    return res

@app.route("/redirect")
def redirect():
    startup.getUserToken(request.args['code'])
    return render_template("redirect.html")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I navigate to the /spotify page on my website, I don't even make it to the spotify login prompt. I get a 500 Internal Server Error. On the spotify dashboard I have my redirect URI set to "&lt;A href="http://www.drewmi.ch/redirect&amp;quot;," target="_blank"&gt;http://www.drewmi.ch/redirect",&lt;/A&gt;&amp;nbsp;I've found many people have made the mistake there, but I don't think that's the case here.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The flow I'm aiming to have is /spotify -&amp;gt; login -&amp;gt; /redirect -&amp;gt; ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Drew&lt;/P&gt;</description>
      <pubDate>Mon, 27 Jul 2020 20:36:55 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Authorization-Code-Flow-500-Internal-Server-Error-at-initial/m-p/5006041#M807</guid>
      <dc:creator>drew_mich</dc:creator>
      <dc:date>2020-07-27T20:36:55Z</dc:date>
    </item>
  </channel>
</rss>

