revert refresh token to Sync request
This commit is contained in:
parent
8ff063ead3
commit
c589b4300e
@ -15,6 +15,7 @@ use ManiaControl\Files\AsyncHttpRequest;
|
|||||||
use ManiaControl\Commands\CommandListener;
|
use ManiaControl\Commands\CommandListener;
|
||||||
use ManiaControl\Admin\AuthenticationManager;
|
use ManiaControl\Admin\AuthenticationManager;
|
||||||
use ManiaControl\Callbacks\TimerListener;
|
use ManiaControl\Callbacks\TimerListener;
|
||||||
|
use ManiaControl\Utils\WebReader;
|
||||||
|
|
||||||
if (! class_exists('MatchManagerSuite\MatchManagerCore')) {
|
if (! class_exists('MatchManagerSuite\MatchManagerCore')) {
|
||||||
$this->maniaControl->getChat()->sendErrorToAdmins('MatchManager Core is needed to use MatchManagerGSheet plugin. Install it and restart Maniacontrol');
|
$this->maniaControl->getChat()->sendErrorToAdmins('MatchManager Core is needed to use MatchManagerGSheet plugin. Install it and restart Maniacontrol');
|
||||||
@ -35,7 +36,7 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
|||||||
* Constants
|
* Constants
|
||||||
*/
|
*/
|
||||||
const PLUGIN_ID = 156;
|
const PLUGIN_ID = 156;
|
||||||
const PLUGIN_VERSION = 1.0;
|
const PLUGIN_VERSION = 1.1;
|
||||||
const PLUGIN_NAME = 'MatchManager GSheet';
|
const PLUGIN_NAME = 'MatchManager GSheet';
|
||||||
const PLUGIN_AUTHOR = 'Beu';
|
const PLUGIN_AUTHOR = 'Beu';
|
||||||
|
|
||||||
@ -339,9 +340,8 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
|||||||
|
|
||||||
if (!empty($refreshtoken) && !empty($expire) && !empty($clientid) && !empty($clientsecret)) {
|
if (!empty($refreshtoken) && !empty($expire) && !empty($clientid) && !empty($clientsecret)) {
|
||||||
if (time() >= $expire) {
|
if (time() >= $expire) {
|
||||||
$asyncHttpRequest = new AsyncHttpRequest($this->maniaControl, 'https://oauth2.googleapis.com/token?grant_type=refresh_token&client_id=' . $clientid . '&client_secret=' . $clientsecret . '&refresh_token=' . $refreshtoken);
|
$response = WebReader::postUrl('https://oauth2.googleapis.com/token?grant_type=refresh_token&client_id=' . $clientid . '&client_secret=' . $clientsecret . '&refresh_token=' . $refreshtoken);
|
||||||
$asyncHttpRequest->setContentType("application/x-www-form-urlencoded");
|
$json = $response->getContent();
|
||||||
$asyncHttpRequest->setCallable(function ($json, $error) {
|
|
||||||
if (!$json) {
|
if (!$json) {
|
||||||
Logger::logError('Impossible to Google API: ' . $json);
|
Logger::logError('Impossible to Google API: ' . $json);
|
||||||
return;
|
return;
|
||||||
@ -360,9 +360,6 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
|||||||
} else {
|
} else {
|
||||||
$this->maniaControl->getChat()->sendErrorToAdmins('Unkown error');
|
$this->maniaControl->getChat()->sendErrorToAdmins('Unkown error');
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
$asyncHttpRequest->postData(1000);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user