title: Laravel curl request resulted in a `403 Forbidden` response
body: <p>I am working on a laravel based project and I need to import time entries from Toggl account. Toggl seems to have correct API in place but I am not able to pull records via API for some reason. </p>
  
  <p>I am using the below-mentioned library to access Toggl API.  <a href="https://medium.com/laravel-5-the-right-way/using-guzzlehttp-with-laravel-1dbea1f633da" rel="nofollow noreferrer">https://medium.com/laravel-5-the-right-way/using-guzzlehttp-with-laravel-1dbea1f633da</a></p>
  
  <p>I am getting below error on every request to API.
  GuzzleHttp \ Exception \ ClientException (403)
  Client error: <code>GET https://toggl.com/api/v8/time_entries?user_agent=deepak%40gmail.com&amp;workspace_id=257895&amp;with_related_data=1</code> resulted in a <code>403 Forbidden</code> response</p>
  
  <p>I have tried to fix it by adding or removing (below-mentioned) header elements that are sent with each request. But it still does not work. </p>
  
  <pre class="lang-php prettyprint-override"><code>use GuzzleHttp\Exception\GuzzleException;
  use GuzzleHttp\Client;
  
  $client = new Client;
  $credentials = base64_encode('e5e8238ca0fee3ca726e486733c87456:api_token');
  $url = 'https://toggl.com/api/v8/time_entries';
  
  $response = $client-&gt;get($url,
      [
          'referer' =&gt; true,
          'headers' =&gt; [
              'Authorization: Basic ' =&gt; $credentials,
              'Content-Type: application/json',
              'User-Agent' =&gt; 'Mozilla /5.0 (Compatible MSIE 9.0;Windows NT 6.1;WOW64; Trident/5.0)',
              'Accept' =&gt; 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
              'Accept-Encoding' =&gt; 'gzip, deflate, br',
          ],
  
          'query' =&gt; [
              'user_agent' =&gt; 'deepak@gmail.com',
              'workspace_id' =&gt; '8756952',
              'with_related_data' =&gt; true,
  
          ],
          "http_errors" =&gt; false,
      ]);
  dd($response);
  </code></pre>
  
  <p>It should retrieve the records from Toggl and print a JSON on the browser. </p>
  
  <p>Interestingly, I am able to pull records through the command-line interface using the command below. 
  curl -v -u e5e8238ca0fee3ca726e486733c85468:api_token -X GET <a href="https://www.toggl.com/api/v8/time_entries" rel="nofollow noreferrer">https://www.toggl.com/api/v8/time_entries</a></p>
  
  <p>Please know that in the above code snippet, I have changed the API key for obvious reasons.</p>
  
  <p>Thanks</p>