API unable to get a token

Jeremie shared this question 9 years ago
Answered

  1. curl "https://my.zipato.com:443/zipato-web/rest/user/init"
  2. {
  3. "success" : true,
  4. "jsessionid" : "46F57E7964ECFBBCBEEE64A81B50EB52",
  5. "nonce" : "jLcGDNLiFqELaDTv"
  6. }

  1. export nonce=jLcGDNLiFqELaDTv
  2. export password=my_password
  3. sha=`echo -n "$password" | sha1sum | awk '{print $1}'`
  4. token=`echo -n "$nonce$sha" | sha1sum | awk '{print $1}'`
  5. echo $token
  6. 74cec65b53aeaca2ea5b44fbf8345cbff0fb0adc

  1. curl "https://my.zipato.com:443/zipato-web/rest/user/login?username=my_name%40my_domain.com&token=74cec65b53aeaca2ea5b44fbf8345cbff0fb0adc"
  2. {"success":false,"error":"User \"my_name@my_domain.com\" not found or wrong password.","jsessionid":"571A0B2D6A133A3B1F32ECE935C5F452","nonce":"clJdRkCzigFOcLTv"}


Of course my_name%40my_domain.com and my_password are replaced to my real credentials.

Best Answer
photo

'/user/login' also needs JSESSIONID.

It's not problem when calling from browser because it is automatically sent in cookies.

You would need to set some curl options to send cookies with JSESSIONID.

All other request will also need valid (authenticated) JSESSIONID.

Replies (5)

photo
2

'/user/login' also needs JSESSIONID.

It's not problem when calling from browser because it is automatically sent in cookies.

You would need to set some curl options to send cookies with JSESSIONID.

All other request will also need valid (authenticated) JSESSIONID.

photo
1

Great! It works!


Maybe you should talk about this JSESSIONID cookie in API documentation.

photo
1

Thanks for your response and thanks for your work on this API.

photo
1

Hi! Someone could explain to me how to proceed with JSESSIONID, with cURL? Thanks.

photo
1

First JSESSIONID you will get from /user/init and then send it as cookie in every other request.

Leave a Comment
 
Attach a file