title: 403 Forbidden returned by trying to download a video in Java code
body: <p>I want to download an embedded video from a website</p>
  <p>The video is easily accessed in a browser but I'm struggling with getting it in Java</p>
  <p>Below is the network tab with the website open after clicking a play button</p>
  <p><a href="https://i.stack.imgur.com/8CYyn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8CYyn.png" alt="enter image description here" /></a></p>
  <p>If I copy the Request URL add a new tab, paste and hit enter the segment is downloaded</p>
  <p><a href="https://i.stack.imgur.com/w27Db.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/w27Db.png" alt="enter image description here" /></a></p>
  <p>However, if I open a new Incognito window and try that I get 403 Forbidden (I also tried to open the video in Incognito mode, pressed the play button, then copied the url and hit enter, the video downloaded successfully, but I get 403 in Normal mode instead)</p>
  <p><a href="https://i.stack.imgur.com/8HqaD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8HqaD.png" alt="enter image description here" /></a></p>
  <p>I get the same result while running the following code:</p>
  <pre><code>public static void main(String[] args) throws IOException
      {
          String baseUrl = &quot;someUrl/ih4mxuprbnvyb3iihebxt26uxqo5x32qhldeyaejlhbmm7kga7llvftoqdia/seg-1-v1-a1.ts&quot;;
          URL url = new URL(baseUrl);
  
          HttpURLConnection con = (HttpURLConnection) url.openConnection();
  
          con.setRequestMethod(&quot;GET&quot;);
  
          con.setRequestProperty(&quot;sec-ch-ua&quot;, &quot;\&quot;Google Chrome\&quot;;v=\&quot;87\&quot;, \&quot; Not;A Brand\&quot;;v=\&quot;99\&quot;, \&quot;Chromium\&quot;;v=\&quot;87\&quot;&quot;);
          con.setRequestProperty(&quot;Accept&quot;, &quot;*/*&quot;);
          con.setRequestProperty(&quot;Upgrade-Insecure-Requests&quot;, &quot;1&quot;);
          con.setRequestProperty(&quot;sec-ch-ua-mobile&quot;, &quot;?0&quot;);
          con.setRequestProperty(&quot;User-Agent&quot;, &quot;Mozilla/5.0 (Macintosh; Intel Mac OS X 11_0_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36&quot;);
  
          System.out.println(con.getResponseCode());
  
      }
  </code></pre>
  <p>I've tried adding the same headers but it didn't work. What am I missing? Thanks in advance</p>