title: Ruby POST call from server fails
body: <p>I'm trying to make a spotify web manager with ruby, to make that I'm following the <a href="https://developer.spotify.com/web-api/authorization-guide/#authorization_code_flow" rel="nofollow">Authorization Guide</a>.</p>
  
  <p>My backend looks similar to the example made by the spotify's guys in this <a href="https://github.com/spotify/web-api-auth-examples/blob/master/authorization_code/app.js" rel="nofollow">github</a>. You can see mine here <a href="https://github.com/emoriarty/spotplayer/blob/master/app.rb" rel="nofollow">code here</a>.</p>
  
  <p>So the error I'm getting are 400 - Bad request or 415 - Unsupported media type.</p>
  
  <p>At first I was using the net/http core library, but because maybe I was doing something wrong I've used <a href="https://github.com/typhoeus/typhoeus" rel="nofollow">Typhoeus</a> and the result are the same.</p>
  
  <p>This is the code is not working:</p>
  
  <pre><code>request = Typhoeus::Request.new("https://accounts.spotify.com/api/token",
    method: :post,
    body: { 
      grant_type: "authorization_code",
      code: code,
      redirect_uri: "http://localhost:5000/auth/spotify/callback"
    },
    headers: { 
      "Authorization": "Basic #{Base64.strict_encode64("#{settings.spotify_id}:#{settings.spotify_key}")}"
    },
    followlocation: true
  )
  
  logger.info request.inspect
  
  request.on_complete do |response|
    logger.info "[]" * 100
    logger.info response
    if response.success?
      logger.info "SUCCESS"
    elsif response.timed_out?
      logger.info "TIMED OUT"
    elsif response.code == 0
      logger.info response.return_message
    else
      logger.info "HTTP request failed: #{response.code.to_s}"
      redirect '/auth/failure'
    end
  end
  
  request.run
  </code></pre>
  
  <p>Well, if someone of you have any idea of what is happenning, It would be helpful to know it.</p>
  
  <p>Thanks in advance.</p>
  
  <p><strong>Edit</strong></p>
  
  <p>The string interpolation is is working properly, has been tested on console.</p>
  
  <pre><code>"Basic #{Base64.strict_encode64("#{settings.spotify_id}:#{settings.spotify_key}")}"
  </code></pre>
  
  <p>About the <strong>redirect_uri</strong>, must to work well, one thing because the guide is explained with localhost example, and second, the first request explained on the <a href="https://developer.spotify.com/web-api/authorization-guide/#authorization_code_flow" rel="nofollow">Authorization Guide</a> is working properly, the problem happens when I'm trying to do the 4 step on that guide.</p>