-
Notifications
You must be signed in to change notification settings - Fork 0
Authorisations
Max Kovpak edited this page Oct 17, 2017
·
1 revision
The API supports the OAuth 2.0 authentication protocol. First you must ask support help for getting unique client_id and client_secret.
require_once 'vendor/autoload.php';
use Brainfab\MoyGrafik\MoyGrafik;
$OAUTH2_CLIENT_ID = 'your client id';
$OAUTH2_CLIENT_SECRET = 'your client secret';
$client = new MoyGrafik();
$client->setClientId($OAUTH2_CLIENT_ID);
$client->setClientSecret($OAUTH2_CLIENT_SECRET);
$client->authenticate([
'grant_type' => 'password',
'username' => 'your email',
'password' => 'your password',
]);
After you can retrieve current auth token
and refresh token
and store it, for example in session:
require_once 'vendor/autoload.php';
session_start();
use Brainfab\MoyGrafik\MoyGrafik;
$OAUTH2_CLIENT_ID = 'your client id';
$OAUTH2_CLIENT_SECRET = 'your client secret';
$client = new MoyGrafik();
$client->setClientId($OAUTH2_CLIENT_ID);
$client->setClientSecret($OAUTH2_CLIENT_SECRET);
if (empty($_SESSION['_token'])) {
$client->authenticate([
'grant_type' => 'password',
'username' => 'your email',
'password' => 'your password',
]);
$_SESSION['_token'] = $client->getAccessToken();
}
if (isset($_SESSION['_token'])) {
$client->setAccessToken($_SESSION['_token']);
}