AnsweredAssumed Answered

how generate token?

Question asked by CloudingSoft on Jun 5, 2016

Hello I am following the guide php and javascript to generate token's Implementing App Login | ArcGIS for Developers 

but I can not do not know what is missing me.

I registered an application and set the CLIENT_ID and client_secret:


$params = array(
    'client_id' => "15yv5x0SU52gG9vU",
    'client_secret' => "24550d44d4aa4f7d9525ae9143289ede",
    'grant_type' => 'client_credentials',
    'f' => 'json'

try {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "");
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, true);
    $response = curl_exec($ch);
} catch (Exception $e) {
    error_log($e->getMessage(), 0);

$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$body = substr($response, $header_size);
$json = json_decode($body, true);
$token = $json['access_token'];