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\Admin\AuthenticationManager;
|
||||
use ManiaControl\Callbacks\TimerListener;
|
||||
use ManiaControl\Utils\WebReader;
|
||||
|
||||
if (! class_exists('MatchManagerSuite\MatchManagerCore')) {
|
||||
$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
|
||||
*/
|
||||
const PLUGIN_ID = 156;
|
||||
const PLUGIN_VERSION = 1.0;
|
||||
const PLUGIN_VERSION = 1.1;
|
||||
const PLUGIN_NAME = 'MatchManager GSheet';
|
||||
const PLUGIN_AUTHOR = 'Beu';
|
||||
|
||||
@ -339,9 +340,8 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
|
||||
if (!empty($refreshtoken) && !empty($expire) && !empty($clientid) && !empty($clientsecret)) {
|
||||
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);
|
||||
$asyncHttpRequest->setContentType("application/x-www-form-urlencoded");
|
||||
$asyncHttpRequest->setCallable(function ($json, $error) {
|
||||
$response = WebReader::postUrl('https://oauth2.googleapis.com/token?grant_type=refresh_token&client_id=' . $clientid . '&client_secret=' . $clientsecret . '&refresh_token=' . $refreshtoken);
|
||||
$json = $response->getContent();
|
||||
if (!$json) {
|
||||
Logger::logError('Impossible to Google API: ' . $json);
|
||||
return;
|
||||
@ -360,9 +360,6 @@ class MatchManagerGSheet implements CallbackListener, TimerListener, CommandLis
|
||||
} else {
|
||||
$this->maniaControl->getChat()->sendErrorToAdmins('Unkown error');
|
||||
}
|
||||
});
|
||||
|
||||
$asyncHttpRequest->postData(1000);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user