Page 1 of 1

Agent Events Push, get2post.php & authentication

PostPosted: Wed May 16, 2018 9:34 am
by vicinewman
Making integration of our CRM with Vicidial. Trying to use HTTP Push events to an external server thought the script get2post.php.
As we see get2post.php doesn't have any authentication.

On the external server we have an API with a basic authentication, so how to make an authentication on Vicidial side before making callbacks, any suggestions?
To modify get2post.php or there is any other build in functions ?

Re: Agent Events Push, get2post.php & authentication

PostPosted: Wed May 16, 2018 9:47 am
by mflorell
Please explain in more detail what you mean by "authentication", since this could mean many different things.

Re: Agent Events Push, get2post.php & authentication

PostPosted: Fri May 18, 2018 9:31 am
by vicinewman
Hi Matt !

Will try to be more clear.
Our API, on the external server side, has HTTP/HTTPS Basic access authentication (RFC 7617) to preven "from being used" any others except Vicidial.
So, right now when Vicidial sends some Agent's Events through the script get2post.php to the external server it can't pass the data through the API.
As get2post.php doesn't support Basic access authentication needed to handshake with the API on the external server over HTTP/HTTPS.

Any suggestions how to solve this issue ?

Thanks!

Re: Agent Events Push, get2post.php & authentication

PostPosted: Fri May 18, 2018 12:28 pm
by blackbird2306
You should be able to use basic authentication with setting the "headers" in your url or you need to alter the code in get2post.php and add curl options "CURLOPT_HTTPAUTH" and "CURLOPT_USERPWD".
Solution 1 (without any changes in code):
1. First you need to base64 encode the username and password in this format: username:password
e.g. try https://www.base64encode.org/ --> user1:pass1 would be "dXNlcjE6cGFzczE=" base64 encoded
2. Then your header should be like this: "Authorization: Basic dXNlcjE6cGFzczE="
3. Set you push event url (replace "dXNlcjE6cGFzczE=" with your base64 encoded string):
Code: Select all
get2post.php?uniqueid=--A--epoch--B--.--A--agent_log_id--B--&type=event&&headers=Authorization---Basic dXNlcjE6cGFzczE=&HTTPURLTOPOST=192.168.1.3/agc/vdc_call_url_test.php?user=--A--user--B--&lead_id=--A--lead_id--B--&event=--A--event--B--&message=--A--message--B--


Solution 2:
1. Change get2post.php (curl part starting at line 158 in revision from 2017-05-31):
Code: Select all
      curl_setopt_array($curl, array(
        // add next 2 lines and change user and pass with your real user credentials
         CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
         CURLOPT_USERPWD => 'user:pass',
         CURLOPT_RETURNTRANSFER => 1,
         CURLOPT_POST => 1,
         CURLOPT_URL => $post_page,
         CURLOPT_POSTFIELDS => $post_vars,
         CURLOPT_HTTPHEADER => $HTTPheader,
         CURLOPT_USERAGENT => 'VICIdial get2post'
      ))

Re: Agent Events Push, get2post.php & authentication

PostPosted: Fri May 18, 2018 1:34 pm
by vicinewman
blackbird2306 wrote:You should be able to use basic authentication with setting the "headers" in your url or you need to alter the code in get2post.php and add curl options "CURLOPT_HTTPAUTH" and "CURLOPT_USERPWD".


Thanks, we will try it