title: Unable to retrieve private release asset from Github using ansible
body: <p>I'm trying to automatically download a release asset using ansible, but I receive a 400 &quot;Invalid Argument error&quot;:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
      &lt;Error&gt;
          &lt;Code&gt;InvalidArgument&lt;/Code&gt;
      &lt;Message&gt;
          Only one auth mechanism allowed;
          only the X-Amz-Algorithm query parameter, Signature query string parameter
          or the Authorization header should be specified
      &lt;/Message&gt;
      &lt;ArgumentName&gt;Authorization&lt;/ArgumentName&gt;
      &lt;ArgumentValue&gt;Basic XXX&lt;/ArgumentValue&gt;
      &lt;RequestId&gt;XXXX&lt;/RequestId&gt;
      &lt;HostId&gt;XXXX&lt;/HostId&gt;
  &lt;/Error&gt;
  </code></pre>
  <p>I have found a <a href="https://github.com/octokit/rest.js/issues/967" rel="nofollow noreferrer">corresponding issue</a> on GitHub, but I can't implement the solution using ansible without writing a custom script. My curremt code is:</p>
  <pre><code>- name: Download build asset
    uri:
      url: &quot;{{ asset_url }}&quot;
      user: &quot;{{ github_username }}&quot;
      password: &quot;{{ github_token }}&quot;
      force_basic_auth: yes
      headers:
        Accept: application/octet-stream
  </code></pre>
  <p>I have also tried passing no headers and using the token in the url</p>
  <pre><code>- name: Download build asset
    uri:
      url: &quot;https://{{ TOKEN }}:@api.github.com/repos/&lt;ORG&gt;/&lt;REPO&gt;/releases/assets/{{ ASSET_ID }}&quot;
      headers:
        Accept: application/octet-stream
  </code></pre>
  <p>But then I receive an error 404 &quot;Not found&quot; Error (presumably because the authentication did not work (private URL parameters replaced as ):</p>
  <pre><code>fatal: [XXX]: FAILED! =&gt; changed=false
    access_control_allow_origin: '*'
    access_control_expose_headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset
    connection: close
    content: '{&quot;message&quot;:&quot;Not Found&quot;,&quot;documentation_url&quot;:&quot;https://docs.github.com/rest/reference/repos#get-a-release-asset&quot;}'
    content_length: '110'
    content_security_policy: default-src 'none'
    content_type: application/json; charset=utf-8
    date: Wed, 18 Nov 2020 15:45:42 GMT
    elapsed: 0
    json:
      documentation_url: https://docs.github.com/rest/reference/repos#get-a-release-asset
      message: Not Found
    msg: 'Status code was 404 and not [200]: HTTP Error 404: Not Found'
    redirected: false
    referrer_policy: origin-when-cross-origin, strict-origin-when-cross-origin
    server: GitHub.com
    status: 404
    strict_transport_security: max-age=31536000; includeSubdomains; preload
    url: https://&lt;TOKEN&gt;@api.github.com/repos/&lt;ORG&gt;/&lt;REPO&gt;/releases/assets/28089234
    vary: Accept-Encoding, Accept, X-Requested-With
    x_content_type_options: nosniff
    x_frame_options: deny
    x_github_media_type: unknown
    x_github_request_id: CC26:2942:15E1154:1948AE9:5FB541A6
    x_ratelimit_limit: '60'
    x_ratelimit_remaining: '58'
    x_ratelimit_reset: '1605717756'
    x_ratelimit_used: '2'
    x_xss_protection: 1; mode=block
  </code></pre>
  <p>This only happens for release assets, other api calls work just fine using the basic auth method. It also works fine with the same request using curl or postman. Scopes for the Personal Access Token I use are:</p>
  <ul>
  <li>repo (full access)</li>
  <li>workflow</li>
  <li>write:packages
  <ul>
  <li>read:packages</li>
  </ul>
  </li>
  </ul>
  <hr />
  <h2>Update</h2>
  <p>For now sending the request using curl works, but I would prefer using the uri module:</p>
  <pre><code>name: Download build asset
    shell: &gt;
      curl -J -L -H &quot;Accept: application/octet-stream&quot;
      &quot;https://{{ TOKEN }}@api.github.com/repos/&lt;ORG&gt;/&lt;REPO&gt;/releases/assets/{{ ASSET_ID }}&quot;
      --output &quot;/tmp/asset.tar.gz&quot;
  </code></pre>