title: How to add authentication header to curl command to request resources?
body: <p>This question has repeated and I have seen many different answers however it did not work for me yet! I have a server set up with ruby in rails.</p>
  
  <p>My first command through terminal which works fine and receive an access token:</p>
  
  <pre><code>curl -i -X POST -d 'member_id=123456789&amp;access_code=password&amp;device_id=1234567890' https://myserver/customer_authentication
  </code></pre>
  
  <p>Specification says to request for resources:</p>
  
  <pre><code>The request requires an authorization header.
  </code></pre>
  
  <p>Beside this:</p>
  
  <p>The user's online access token that is stored in the authorization header will be used to look up the user. The anonymised user identifier will be used to lookup the customer info as well and ensures a correlation with the customer associated with the access token.
  Example: header['Authorization'] = "Bearer online_banking_access_token"</p>
  
  <p>Now I am trying to get list of data from server, which in specification says:</p>
  
  <pre><code>GET /org1/customers/:acid/accounts
  </code></pre>
  
  <p>This will return a json of user's account. I have used these but neither worked for me:</p>
  
  <pre><code>curl -H GET Authorization: "348129" https://myserver/api/org1/customers/:acid/accounts
  
  curl –H GET "Authorization: Token 348129" https://myserver/api/org1/customers/:acid/accounts
  </code></pre>
  
  <p>This is the code on the server:</p>
  
  <pre><code>  if @customer &amp;&amp; authenticated_customer_matches_requested_customer
      body = { accounts: array_of_account_hashes }
      status_code = :ok
    else
      body = { error_message: 'Invalid access token' }.to_json
      status_code = :unauthorized
    end
  </code></pre>
  
  <p>And I receive:</p>
  
  <pre><code>{"error_message":"Invalid access token"}
  </code></pre>