forked from Wavyzz/dolibarr
Debug refresh action and add log in oauth
This commit is contained in:
@@ -145,13 +145,15 @@ if ($action == 'refreshtoken' && $user->admin) {
|
||||
//var_dump($expire);
|
||||
|
||||
// We do the refresh even if not expired, this is the goal of action.
|
||||
$credentials = new Credentials(
|
||||
getDolGlobalString('OAUTH_'.strtoupper($OAUTH_SERVICENAME).'_ID'),
|
||||
getDolGlobalString('OAUTH_'.strtoupper($OAUTH_SERVICENAME).'_SECRET'),
|
||||
getDolGlobalString('OAUTH_'.strtoupper($OAUTH_SERVICENAME).'_URLAUTHORIZE')
|
||||
);
|
||||
$serviceFactory = new \OAuth\ServiceFactory();
|
||||
$oauthname = explode('-', $OAUTH_SERVICENAME);
|
||||
$keyforoauthservice = strtoupper($oauthname[0]).(empty($oauthname[1]) ? '' : '-'.$oauthname[1]);
|
||||
$credentials = new Credentials(
|
||||
getDolGlobalString('OAUTH_'.$keyforoauthservice.'_ID'),
|
||||
getDolGlobalString('OAUTH_'.$keyforoauthservice.'_SECRET'),
|
||||
getDolGlobalString('OAUTH_'.$keyforoauthservice.'_URLAUTHORIZE')
|
||||
);
|
||||
|
||||
$serviceFactory = new \OAuth\ServiceFactory();
|
||||
// ex service is Google-Emails we need only the first part Google
|
||||
$apiService = $serviceFactory->createService($oauthname[0], $credentials, $storage, array());
|
||||
|
||||
|
||||
@@ -60,12 +60,14 @@ class StreamClient extends AbstractClient
|
||||
//var_dump($requestBody); var_dump($extraHeaders);var_dump($method);exit;
|
||||
$context = $this->generateStreamContext($requestBody, $extraHeaders, $method);
|
||||
|
||||
/*
|
||||
var_dump($endpoint->getAbsoluteUri());
|
||||
var_dump($requestBody);
|
||||
var_dump($method);
|
||||
var_dump($extraHeaders);
|
||||
*/
|
||||
// @CHANGE DOL_LDR Add log
|
||||
if (function_exists('getDolGlobalString') && getDolGlobalString('OAUTH_DEBUG')) {
|
||||
file_put_contents(DOL_DATA_ROOT . "/dolibarr_oauth.log", $endpoint->getAbsoluteUri()."\n", FILE_APPEND);
|
||||
file_put_contents(DOL_DATA_ROOT . "/dolibarr_oauth.log", $requestBody."\n", FILE_APPEND);
|
||||
file_put_contents(DOL_DATA_ROOT . "/dolibarr_oauth.log", $method."\n", FILE_APPEND);
|
||||
file_put_contents(DOL_DATA_ROOT . "/dolibarr_oauth.log", var_export($extraHeaders, true)."\n", FILE_APPEND);
|
||||
@chmod(DOL_DATA_ROOT . "/dolibarr_oauth.log", octdec(empty($conf->global->MAIN_UMASK)?'0664':$conf->global->MAIN_UMASK));
|
||||
}
|
||||
|
||||
$level = error_reporting(0);
|
||||
$response = file_get_contents($endpoint->getAbsoluteUri(), false, $context);
|
||||
|
||||
Reference in New Issue
Block a user