<?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 Error In Docker Container in Spotify for Developers</title>
    <link>https://community.spotify.com/t5/Spotify-for-Developers/Invalid-Client-Error-In-Docker-Container/m-p/5660665#M11336</link>
    <description>&lt;P&gt;Yup, I did:&lt;/P&gt;&lt;P&gt;I have&amp;nbsp;&lt;/P&gt;&lt;UL class=""&gt;&lt;LI&gt;&lt;SPAN class=""&gt;&lt;A href="http://localhost:5000/callback" target="_blank" rel="noopener"&gt;http://localhost:5000/callback&lt;/A&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN class=""&gt;&lt;A href="http://127.0.0.1:5000/callback" target="_blank" rel="noopener"&gt;http://127.0.0.1:5000/callback&lt;/A&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;</description>
    <pubDate>Wed, 01 Nov 2023 23:58:53 GMT</pubDate>
    <dc:creator>hi_xavier</dc:creator>
    <dc:date>2023-11-01T23:58:53Z</dc:date>
    <item>
      <title>Invalid Client Error In Docker Container</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Invalid-Client-Error-In-Docker-Container/m-p/5660304#M11334</link>
      <description>&lt;P&gt;Running into an issue with my flask application. When &lt;STRONG&gt;not&lt;/STRONG&gt; running my app inside of a docker container, I'm able to successfully authorize via Spotify API.&lt;/P&gt;&lt;P&gt;1. User navigates to &lt;STRONG&gt;localhost:5000/login&lt;/STRONG&gt;&lt;BR /&gt;2. Spotify authorization agreement is displayed&lt;BR /&gt;3. User clicks "Agree"&lt;BR /&gt;4. User is routed to &lt;STRONG&gt;localhost:5000/callback&lt;/STRONG&gt; where the text "Success" is displayed&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But, when I dockerize the flask app, I get the following error in the browser when the user clicks "Agree" on the authorize page:&lt;/P&gt;&lt;PRE&gt;Internal Server Error&lt;BR /&gt;&lt;BR /&gt;The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On the backend, here's the error i'm getting in the logs&lt;/P&gt;&lt;PRE&gt;{'error': 'invalid_client', 'error_description': 'Invalid client'}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is my Dockerfile, and app.py file&lt;/P&gt;&lt;PRE&gt;Dockerfile &lt;BR /&gt;FROM python:3.9-slim-buster&lt;BR /&gt;WORKDIR /app&lt;BR /&gt;COPY ./requirements.txt /app&lt;BR /&gt;RUN pip install -r requirements.txt&lt;BR /&gt;COPY . .&lt;BR /&gt;EXPOSE 5000&lt;BR /&gt;ENV FLASK_APP=app.py&lt;BR /&gt;CMD ["flask", "run", "--host", "0.0.0.0"]&lt;BR /&gt;&lt;BR /&gt;&lt;/PRE&gt;&lt;PRE&gt;app.py&lt;BR /&gt;from flask import Flask, render_template, flash, session, redirect, request, Response, session, make_response&lt;BR /&gt;from spotify_connector import SpotifyConnector&lt;BR /&gt;connector = SpotifyConnector()&lt;BR /&gt;&lt;BR /&gt;@app.route('/')&lt;BR /&gt;def index():&lt;BR /&gt;return "INDEX"&lt;BR /&gt;&lt;BR /&gt;@app.route('/login')&lt;BR /&gt;def login():&lt;BR /&gt;client_id = app.config['CLIENT_ID']&lt;BR /&gt;redirect_uri = app.config['REDIRECT_URI']&lt;BR /&gt;scope = app.config['SCOPE']&lt;BR /&gt;authorize_url = 'https://accounts.spotify.com/en/authorize?'&lt;BR /&gt;state_key = connector.create_state_key(15)&lt;BR /&gt;session['state_key'] = state_key&lt;BR /&gt;parameters = 'response_type=code&amp;amp;client_id=' + client_id + '&amp;amp;redirect_uri=' + redirect_uri + '&amp;amp;scope=' + scope + '&amp;amp;state=' + state_key&lt;BR /&gt;response = make_response(redirect(authorize_url + parameters))&lt;BR /&gt;return response&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;@app.route('/callback')&lt;BR /&gt;def callback():&lt;BR /&gt;code = request.args.get('code', None)&lt;BR /&gt;state = request.args.get('state', None)&lt;BR /&gt;session.pop('state_key', None)&lt;BR /&gt;payload = connector.getToken(code)&lt;BR /&gt;if payload is not None:&lt;BR /&gt;session['access_token'] = payload['access_token']&lt;BR /&gt;session['refresh_token'] = payload['refresh_token']&lt;BR /&gt;return "SUCCESS"&lt;BR /&gt;else:&lt;BR /&gt;return "FAILURE"&lt;BR /&gt;&lt;BR /&gt;if __name__ == "__main__":&lt;BR /&gt;app.run(host="localhost")&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 09:31:05 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Invalid-Client-Error-In-Docker-Container/m-p/5660304#M11334</guid>
      <dc:creator>hi_xavier</dc:creator>
      <dc:date>2023-11-01T09:31:05Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid Client Error In Docker Container</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Invalid-Client-Error-In-Docker-Container/m-p/5660427#M11335</link>
      <description>&lt;P&gt;Did you add the adress:port of the docker container&amp;nbsp;to the &lt;EM&gt;callback URIs&lt;/EM&gt; at the dashboard of your app?&lt;/P&gt;</description>
      <pubDate>Wed, 01 Nov 2023 14:58:50 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Invalid-Client-Error-In-Docker-Container/m-p/5660427#M11335</guid>
      <dc:creator>Ximzend</dc:creator>
      <dc:date>2023-11-01T14:58:50Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid Client Error In Docker Container</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Invalid-Client-Error-In-Docker-Container/m-p/5660665#M11336</link>
      <description>&lt;P&gt;Yup, I did:&lt;/P&gt;&lt;P&gt;I have&amp;nbsp;&lt;/P&gt;&lt;UL class=""&gt;&lt;LI&gt;&lt;SPAN class=""&gt;&lt;A href="http://localhost:5000/callback" target="_blank" rel="noopener"&gt;http://localhost:5000/callback&lt;/A&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN class=""&gt;&lt;A href="http://127.0.0.1:5000/callback" target="_blank" rel="noopener"&gt;http://127.0.0.1:5000/callback&lt;/A&gt;&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Wed, 01 Nov 2023 23:58:53 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Invalid-Client-Error-In-Docker-Container/m-p/5660665#M11336</guid>
      <dc:creator>hi_xavier</dc:creator>
      <dc:date>2023-11-01T23:58:53Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid Client Error In Docker Container</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Invalid-Client-Error-In-Docker-Container/m-p/5660747#M11337</link>
      <description>&lt;P&gt;&lt;EM&gt;CMD ["flask", "run", "--host", "&lt;STRONG&gt;0.0.0.0&lt;/STRONG&gt;"]&amp;nbsp;&lt;/EM&gt;?&lt;/P&gt;</description>
      <pubDate>Thu, 02 Nov 2023 06:16:52 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Invalid-Client-Error-In-Docker-Container/m-p/5660747#M11337</guid>
      <dc:creator>Ximzend</dc:creator>
      <dc:date>2023-11-02T06:16:52Z</dc:date>
    </item>
    <item>
      <title>Re: Invalid Client Error In Docker Container</title>
      <link>https://community.spotify.com/t5/Spotify-for-Developers/Invalid-Client-Error-In-Docker-Container/m-p/5661185#M11349</link>
      <description>&lt;P&gt;In the part of my code that generates the token for Spotify (where the error was originating), I was retrieving my client id and secret by using:&lt;BR /&gt;CLIENT_ID = os.getenv("CLIENT_ID")&lt;/P&gt;&lt;P&gt;CLIENT_SECRET = os.getenv("CLIENT_SECRET")&lt;/P&gt;&lt;P&gt;I threw in a print stament, and saw that Authorization header looked like this --Authorization: Basic "":"" , when it should look like this Authorization: Basic CLIENT_ID:CLIENT_SECRET. This confirmed that CLIENT_ID and CLIENT_SECRET weren't available.&lt;/P&gt;&lt;P&gt;I added the following to my Dockerfile, and I'm now able to successfully authorize:&lt;/P&gt;&lt;P&gt;ENV CLIENT_ID=*****&lt;/P&gt;&lt;P&gt;ENV CLIENT_SECRET=*****&lt;/P&gt;&lt;P&gt;Going further, I'm most likely going to get rid of the above two ENV declarations, and add the os.getenv declarations to my flask app config file.&lt;/P&gt;</description>
      <pubDate>Fri, 03 Nov 2023 00:15:58 GMT</pubDate>
      <guid>https://community.spotify.com/t5/Spotify-for-Developers/Invalid-Client-Error-In-Docker-Container/m-p/5661185#M11349</guid>
      <dc:creator>hi_xavier</dc:creator>
      <dc:date>2023-11-03T00:15:58Z</dc:date>
    </item>
  </channel>
</rss>

