title: Error Authenticating Spotify - Bad Request
body: <p>I'm having a hard time trying to authenticate my <code>spotify</code> app on <code>localhost</code>. I have my <code>redirect_uri</code> set as <code>localhost:8888/callback</code> (have also tried it with <code>http://</code>) at my developer account, but I get this error page when terminal prompts me to enter the URL I'm being redirected to.</p>
  <p>I am running my server using <code>python -m SimpleHTTPServer 8888</code>, and entering at terminal <code>python script.py username</code>.</p>
  <p>This is my Python script:</p>
  <pre><code>scope = 'user-library-read'
  
  if len(sys.argv) &gt; 1:
      username = sys.argv[1]
  else:
      print &quot;Usage: %s username&quot; % (sys.argv[0],)
      sys.exit()
  
  token = util.prompt_for_user_token(username, scope, client_id='myId', client_secret='mySecret', redirect_uri='localhost:8888/callback')
  
  if token:
      sp = spotipy.Spotify(auth=token)
      results = sp.current_user_saved_tracks()
      for item in results['items']:
          track = item['track']
          print track['name'] + ' - ' + track['artists'][0]['name']
  else:
      print &quot;Can't get token for&quot;, username
  </code></pre>
  <p>This is the log:</p>
  <pre><code>    token_info = sp_oauth.get_access_token(code)
    File &quot;/Library/Python/2.7/site-packages/spotipy/oauth2.py&quot;, line 210, in get_access_token
      raise SpotifyOauthError(response.reason)
  spotipy.oauth2.SpotifyOauthError: Bad Request
  </code></pre>
  <p>What could be wrong?</p>