This object is in archive! 
API v2 - Login Jquery, Ajax, Javascript
Answered
As I understood;
- call "user/init" (get "jsessionid" and "nonce")
- calculate the token (with SHA-1)
- login
But it always response like this;
{"success": false,"error": "[User my_mail@gmail.com not found or wrong password]","jsessionid": "FA9E99D47890D97D3CEAE19A4639FF0C-n1.frontend3","nonce": "roxgMfBEMeylqhVH"}
Is there anybody help to me?
No connection
Real-time notifications may not work
Hi Ersen.
The following works for me, even when I still get the error: Refused to set unsafe header "Cookie"
I used the following libraries:
Make sure that you are logged out before trying.
With Chrome I used:
chrome.exe --user-data-dir="C:/Chrome dev session" --disable-web-security
I hope it works for you as well.
But of course it is a problem that the jsessionid is set through a header cookie which is not supposed to be used with JS. I guess it will still causes problems.
EDIT: Is there a reason why you want it with JS only?
Hi Ersen.
The following works for me, even when I still get the error: Refused to set unsafe header "Cookie"
I used the following libraries:
Make sure that you are logged out before trying.
With Chrome I used:
chrome.exe --user-data-dir="C:/Chrome dev session" --disable-web-security
I hope it works for you as well.
But of course it is a problem that the jsessionid is set through a header cookie which is not supposed to be used with JS. I guess it will still causes problems.
EDIT: Is there a reason why you want it with JS only?
Hello, we are sending steps for the login to our server. Please check all the steps and see if you have made everything right.
1) Initialize user session - it will give you nonce that you are using in the next API call.
URL: [GET] https://my.zipato.com/zipato-web/v2/user/init
Header { Accept: 'application/json' }
Response: { success: true, jsessionid: 'F91D548CE337896E2358668FD82D0B33-n1.frontend3', nonce: 'CCiLOjZjIGjfSBuj'}
NOTE: jessionId from response should be used in any other call to the server:
Cookie: JSESSIONID=F91D548CE337896E2358668FD82D0B33-n1.frontend3
2) Calculate user token
User data for this example: {username: 'username@xxx.com', password: 'password'}
Algorithm for calculating token.
token = hash(nonce + hash(password))
Calculation steps:
token = hash('CCiLOjZjIGjfSBuj' + hash('password')
token = hash('CCiLOjZjIGjfSBuj' + '5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8')
token = 'ced228631af6a88595e4fb78912e5f5b5ccddae7'
NOTE: Use this link []http://www.sha1-online.com/]; to check that your function returns correct SHA1 result.
3) Login user using token and username
URL: [GET] https://my.zipato.com/zipato-web/v2/user/login
Params: { token: 'ced228631af6a8859e4fb78923e6f6b6ccdae7', username: 'username@xxx.com' }
Header:
Accept: application/json
Cookie: JSESSIONID=F91D548CE337896E2358668FD82D0B33-n1.frontend3
Note: If you get false in response, like 'username not found or wrong password' and you have followed this steps,
try to clear session using URL: https://my.zipato.com/zipato-web/v2/user/logout.
Repeat the steps again.
If you still have problems with login, contacts us back so we can check all your steps and request data.
Hello, we are sending steps for the login to our server. Please check all the steps and see if you have made everything right.
1) Initialize user session - it will give you nonce that you are using in the next API call.
URL: [GET] https://my.zipato.com/zipato-web/v2/user/init
Header { Accept: 'application/json' }
Response: { success: true, jsessionid: 'F91D548CE337896E2358668FD82D0B33-n1.frontend3', nonce: 'CCiLOjZjIGjfSBuj'}
NOTE: jessionId from response should be used in any other call to the server:
Cookie: JSESSIONID=F91D548CE337896E2358668FD82D0B33-n1.frontend3
2) Calculate user token
User data for this example: {username: 'username@xxx.com', password: 'password'}
Algorithm for calculating token.
token = hash(nonce + hash(password))
Calculation steps:
token = hash('CCiLOjZjIGjfSBuj' + hash('password')
token = hash('CCiLOjZjIGjfSBuj' + '5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8')
token = 'ced228631af6a88595e4fb78912e5f5b5ccddae7'
NOTE: Use this link []http://www.sha1-online.com/]; to check that your function returns correct SHA1 result.
3) Login user using token and username
URL: [GET] https://my.zipato.com/zipato-web/v2/user/login
Params: { token: 'ced228631af6a8859e4fb78923e6f6b6ccdae7', username: 'username@xxx.com' }
Header:
Accept: application/json
Cookie: JSESSIONID=F91D548CE337896E2358668FD82D0B33-n1.frontend3
Note: If you get false in response, like 'username not found or wrong password' and you have followed this steps,
try to clear session using URL: https://my.zipato.com/zipato-web/v2/user/logout.
Repeat the steps again.
If you still have problems with login, contacts us back so we can check all your steps and request data.
Dear Mirjana,
Thank you for your response.
But i am trying to develope ui with jquery via your api. I can not send "Cookie" with javascript, and also your web api are not allowed cross domain requests.
Is it by design not to allow using web api from browser based applications or just missing feature/option of the api?
Allowing such requests would significantly extend interoperability of Zipato Cloud.
Dear Mirjana,
Thank you for your response.
But i am trying to develope ui with jquery via your api. I can not send "Cookie" with javascript, and also your web api are not allowed cross domain requests.
Is it by design not to allow using web api from browser based applications or just missing feature/option of the api?
Allowing such requests would significantly extend interoperability of Zipato Cloud.
I still don't understand how to do it
I need so that my voice assistant can take values from the sensors
How to create a link
"https://my.zipato.com:443/zipato-web/v2/attributes/XXXXXXXX-382d-4776-839a-XXXXXXXXXXXX/value/value"
Help please
I still don't understand how to do it
I need so that my voice assistant can take values from the sensors
How to create a link
"https://my.zipato.com:443/zipato-web/v2/attributes/XXXXXXXX-382d-4776-839a-XXXXXXXXXXXX/value/value"
Help please
Replies have been locked on this page!