/
var
/
www
/
html
/
plugin-techloyce
/
Modules
/
SubscriptionFlowServices
/
Services
/
Upload File
HOME
<?php namespace Modules\SubscriptionFlowServices\Services; use GuzzleHttp\Client; class AuthorizationService { protected $clientID; protected $clientSecret; protected $baseUrl; public function __construct($baseUrl, $clientID, $clientSecret) { $this->clientID = $clientID; $this->clientSecret = $clientSecret; $this->baseUrl = $baseUrl; } public function getAccessToken() { $url = $this->baseUrl . '/oauth/token'; $client = new Client(); $params['client_id'] = $this->clientID; $params['client_secret'] = $this->clientSecret; $params['grant_type'] = 'client_credentials'; $request = $client->post($url, ['form_params' => $params]); $response = $request->getBody()->getContents(); $response_data = json_decode($response, true); return $response_data['access_token']; } }