title: CKAN - use API with curl and Apache basic authentication
body: <p>I create resources in Ckan using curl and everything works:</p>
  
  <p><code>curl -H'Authorization: zzzzzz-zzzzz-zzzzz-zzzzz-zzzzzz' 'https://ckan.site.com/api/action/resource_create' --form upload=@/home/file.csv --form package_id=test-upload-file --form url='' --form name='test 12' --form format='csv'</code></p>
  
  <p>But if Ckan is on an Apache web server with basic-auth (so when I try to log into the web interface a popup asking for username and password appears) curl stops working. I add -u option to curl command to pass username and password to the web server, but I always receive an "Unauthorized" answer from Apache; I also tried passing username and password with <a href="http://username:password@ckan.site.com" rel="nofollow noreferrer">http://username:password@ckan.site.com</a> or with -n and .netrc file, but I had no luck.</p>
  
  <p>I am suspecting that Apache is messing with "Authorization" header: one is passed with curl and -H option, and another because there is basic authentication configured in Apache  (<a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Authorization" rel="nofollow noreferrer">documentation here</a>) ... maybe they mix up?
  If I try to simply <code>curl -n https://ckan.site.com/</code> I can download Ckan homepage.</p>
  
  <p>Here is Apache basic auth configuration:</p>
  
  <pre><code>&lt;Location /&gt;
  AuthType Basic
  AuthName "ckan login"
  AuthUserFile /etc/apache2/.htpasswd
  Require valid-user
  &lt;/Location&gt;
  </code></pre>
  
  <p>And here is the auth_basic error that I see in Apache logs:</p>
  
  <p><code>client used wrong authentication scheme: /api/action/resource_create</code></p>