title: Force Content-Type or expose request.data in Flask for known content-type
body: <p>I am recreating a service in Python/Flask and am running into an issue with the way the existing clients authenticate. I have to match the existing clients scheme for compatibility reasons.</p>
  
  <p>The existing clients take the username, password and base64 encode it. This is not HTTP Basic Authentication, despite sounding similar. Below is some sample code that would create this login request. </p>
  
  <pre><code>credentials = {
              'username': 'test@example.com',
              'password': 'password'
  }
  data = b64encode(urlencode(credentials))
  request = urllib2.Request(loginURL)
  request.add_data(data)
  # request.add_header('Content-Type', 'application/gooblygop')
  # 'application/x-www-form-urlencoded' seems to be a default Content-Type
  login = urllib2.urlopen(request)
  </code></pre>
  
  <p>On the server side, I take the POST data and base64 decode it to get the username and password information again. </p>
  
  <pre><code>flask server:
  @app.route('/login', methods=['POST'])
  def login():
      error = None
      if request.method == 'POST':
          # post data: cGFzc3dvcmQ9ZGVmYXVsdCZlbWFpbD10ZXN0JTQwZXhhbXBsZS5jb20=
          data = b64decode(request.data)
          # decoded data: password=default&amp;email=test%40example.com
          return('ok')
  </code></pre>
  
  <p>The problem is the Content Type. If I specify an unknown Content-Type in the client (application/gooblygop), Flask exposes the POST data to request.data and I can decode the base64 string. If I leave the Content-Type as default (application/x-www-form-urlencoded), the raw data is not exposed to request.data and I don't know how to retrieve the base64 encoded string and make use of it.</p>
  
  <p>The existing client software all pretty much defaults to x-www-form-urlencoded, but I can't rely on that always being the case. </p>
  
  <p>Essentially, I need a reliable, server-side method for accessing that encoded string no matter what Content-Type the client program states.</p>
  
  <p>Other notes: I am very new to Python, coming from a PHP background. So I am very open to suggestions. Also, this project is primarily for personal use.</p>