Skip to content

Instantly share code, notes, and snippets.

@nidup
Last active March 12, 2017 15:34
Show Gist options
  • Save nidup/45b044b2ba1dcdb70bbe5c24ad05e56b to your computer and use it in GitHub Desktop.
Save nidup/45b044b2ba1dcdb70bbe5c24ad05e56b to your computer and use it in GitHub Desktop.
Akeneo Web API, get token
<?php
$host = "http://pim-ce-17-odm.local/app_dev.php/";
$url = $host."api/oauth/v1/token";
$username = "admin";
$password = "admin";
$clientId = "2_1xkkvxrjku74k4ss8k44kwwsko40o08ckg488ogcosgookgo40";
$secret = "3ps4i6q62r6s0w88ksosso0cc8s4wcc0w4w4gcogo4gwgkkwk4";
$base64 = base64_encode($clientId.":".$secret);
$headers = array();
$headers[] = 'Content-Type: application/json';
$headers[] = 'Authorization: Basic '.$base64;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(['username' => $username, 'password' => $password, "grant_type" => "password"]));
$result = curl_exec($ch);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment