Código PHP:
<?php
function auto($url,$data)
{
$username='demo';
$password='demo123';
$URL='http://url_webservice/token';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$URL);
curl_setopt($ch, CURLOPT_TIMEOUT, 30); //timeout after 30 seconds
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "grant_type=password&[email protected]&password=pass123");
$result=curl_exec($ch);
curl_close ($ch);
return $result;
}
$URL='http://url_webservice/token';
echo auto($URL,$data);
?>
curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
Es la que no tengo la menor idea de como pasarla a angular.