0

im trying to automate a login to Zoho CRM. I'm trying to Log In using my data in a http call but looks like it doesn't work. I would like to know if anyone has achieved this.

What I tried:

POST to https://accounts.zoho.com/login

with body:

{
 LOGIN_ID: "username", 
PASSWORD: "password", 
IS_AJAX: "true", 
remember :-1,  
servicename: "ZohoCRM"
}

The response I get: Status 200

showErrorAndReload('Please\x20reload\x20the\x20page\x20and\x20try\x20again.');

2 Answers 2

0

I just recently had to do a lot of research and trial and error to figure this one out. Be sure to use Postman or something else to test this out for your app.

  1. Get the iamcsr value from the cookie you receive by visiting https://accounts.zoho.com/

    Here is what the value looks like

    Note: You can't reuse or hardcode that value in. Your app has to generate it each login.

  2. Insert the following values into the link below and POST it.

    login_id = your Zoho account login

    password = your Zoho account password

    unix_timestamp = generate a current unix timestamp with milliseconds

    iamcsr = value received from cookie

    The parameter values for remember, servicename, and serviceurl always remain the same.

    https://accounts.zoho.com/signin/auth?LOGIN_ID={login_id}&PASSWORD={password}&cli_time={unix_timestamp}&remember=2592000&iamcsrcoo={iamcsr}&servicename=AaaServer&serviceurl=https://accounts.zoho.com/u/

To verify you have successfully logged in you will receive the following response:

showsuccess('https\x3A\x2F\x2Faccounts.zoho.com\x2Fu\x2F',"",'', '', '-1', 'dXM\x3D');

This will get you through the login portion and will authenticate you to do further actions assuming your app has stored cookies for the current session.

0
0

I made a Php script based on Christian Barahona answer:

  1. Get session cookie
$useragent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36
(KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36';
$cookie_file_path = 'cookie.txt';

$curl = curl_init('https://accounts.zoho.com/signin?servicename=AaaServer&serviceurl=%2Fu%2Fh/');
curl_setopt($curl, CURLOPT_USERAGENT, $useragent); 
curl_setopt($curl,CURLOPT_SSL_VERIFYPEER, FALSE); 
curl_setopt($curl,CURLOPT_SSL_VERIFYHOST, 2); 
curl_setopt($curl, CURLOPT_COOKIEJAR,
$cookie_file_path);

curl_exec($curl);
  1. Login
//Read cookies file
$cookies = curl_getinfo($curl, CURLINFO_COOKIELIST); 
foreach ($cookies as $cookie){
    $splitted=preg_split('/\s+/',$cookie);
    if($splitted[0]=="accounts.zoho.com"){
        if($splitted[sizeof($splitted)-2]=="iamcsr"){
            $iamscr=$splitted[sizeof($splitted)-1];
        }
    } 
} 
//return current unix timestamp in milliseconds
function milliseconds() {
    $mt = explode(' ', microtime());
    return ((int)$mt[1]) * 1000 + ((int)round($mt[0] * 1000)); 
} 

$postValues = array(
    'LOGIN_ID' => '*******',
    'PASSWORD' => '*******',
    'cli_time'=> milliseconds(),
    'remember'=> '2592000',
    'iamcsrcoo'=> $iamscr,
    'servicename'=> 'AaaServer',
    'serviceurl'=> 'https://accounts.zoho.com/u/h' 
);
$postValuesFormatted = http_build_query($postValues);

curl_setopt($curl, CURLOPT_URL, 'https://accounts.zoho.com/signin/auth'); 
curl_setopt($curl, CURLOPT_POST, true); 
curl_setopt($curl, CURLOPT_POSTFIELDS, $postValuesFormatted); 
curl_setopt($curl, CURLOPT_COOKIEFILE, $cookie_file_path);

curl_exec($curl);
  1. Curl any page while logged
curl_setopt($curl, CURLOPT_URL, 'https://accounts.zoho.com/u/h');
curl_setopt($curl, CURLOPT_POST, false);
$result = curl_exec($curl);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.