title: How to use Basic HTTP Django Authorization middleware?
body: <p>I don't understand the django middleware snippet here: <a href="https://djangosnippets.org/snippets/1304/" rel="nofollow noreferrer">https://djangosnippets.org/snippets/1304/</a></p>
  
  <p>I have incorporated the middleware correctly, and upon visiting my site, I can manually enter in the username and password and authenticate. My problem is that I don't know how to send a request from Postman/curl to authenticate. I have included an "Authorization" header in my Postman request, but I don't know how to format the values.</p>
  
  <p>For example: "Authorization: user password"</p>
  
  <pre><code>    def __call__(self, request):
      if 'HTTP_AUTHORIZATION' not in request.META:
          return self._unauthed()
      else:
          authentication = request.META['HTTP_AUTHORIZATION']
          (auth_method, auth) = authentication.split(' ', 1)
          if 'basic' != auth_method.lower():
              return self._unauthed()
          auth = base64.b64decode(auth.strip()).decode('utf-8')
          username, password = auth.split(':', 1)
          if (
              username == settings.BASICAUTH_USERNAME and
              password == settings.BASICAUTH_PASSWORD
          ):
              return self.get_response(request)
  
          return self._unauthed()
  </code></pre>