title: Using cookie authentication with bitbucket and curl
body: <p>I'm trying to login with curl to Bitbucket server and use the created cookie to make another request, but somehow it is not working.</p>
  
  <pre><code>#!/usr/bin/perl
  use strict;
  use Data::Dumper;
  
  my $user        = 'user';
  my $password    = 'pass';
  my $base_url    = 'https://bitbucket.company.com/bitbucket';
  my $project     = 'PROJ';
  my $repository  = 'REPO';
  
  my $login = `curl -s -u $user:$password --cookie-jar \"cookie.txt\" -H \"Content-Type: application/json\" \"$base_url/rest/api/1.0/projects\"`;
  print $login;
  
  my $url = $base_url.'/projects/'.$project.'/repos/'.$repository.'/settings/pull-requests';
  my $pr_page = `curl -s --cookie \"cookie.txt\" -H \"Content-Type: application/json\" -H \"X-Atlassian-Token: no-check\" \"$url\"";
  print $pr_page;
  </code></pre>
  
  <p>The login succeeds and I do get a cookie, it states:</p>
  
  <blockquote>
    <p>Netscape HTTP Cookie File
    <a href="http://curl.haxx.se/docs/http-cookies.html" rel="nofollow">http://curl.haxx.se/docs/http-cookies.html</a>
    This file was generated by libcurl! Edit at your own risk.</p>
    
    <p>HttpOnly_bitbucket.mycompany.com  FALSE   /bitbucket/ TRUE    0   JSESSIONID  8079B4AC59C823137D7A78E4414C7CB3</p>
  </blockquote>
  
  <p>But the script does not return the second page. I think it has something to do with not having the remember-me-cookie, but I can't generate it.</p>
  
  <p>Thanks,<br>
  Rudy</p>