Unable to get access token from azure media services REST API using PHP -
i have next code in php:
define("token_url", "https://wamsprodglobal001acs.accesscontrol.windows.net/v2/oauth2-13"); $arrdata = array( 'grant_type=client_credentials', 'client_id='.client_id, 'client_secret='.urlencode(access_key), 'scope=urn%3awindowsazuremediaservices' ); $arrheader = array( 'content-length:'.strlen($this->generatedata($arrdata)) ); $ch = curl_init(); curl_setopt($ch, curlopt_url, token_url); curl_setopt($ch, curlopt_postfields, $this->generatedata($arrdata)); curl_setopt($ch, curlopt_httpheader, $arrheader); curl_setopt($ch, curlopt_returntransfer, true); $data = curl_exec($ch); curl_close($ch); $arrtoken = json_decode($data);
i unable token code. please can check wrong?
there few issues:
you simplify few things , utilize http_build_query()
:
$data = http_build_query(array( 'grant_type' => 'client_credentials', 'client_id' => client_id, 'client_secret' => access_key, 'scope' => 'urn:windowsazuremediaservices', )); $ch = curl_init(token_url); curl_setopt($ch, curlopt_postfields, $data); curl_setopt($ch, curlopt_returntransfer, 1); if (($res = curl_exec($ch)) === false) { die(curl_error($ch)); } $arrtoken = json_decode($res);
if there's error, first thing create sure whether have updated list of ca certificates.
php rest azure azure-media-services
No comments:
Post a Comment