diff --git a/htdocs/admin/oauthlogintokens.php b/htdocs/admin/oauthlogintokens.php index 505bf30b692..a2200ca69db 100644 --- a/htdocs/admin/oauthlogintokens.php +++ b/htdocs/admin/oauthlogintokens.php @@ -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()); diff --git a/htdocs/includes/OAuth/Common/Http/Client/StreamClient.php b/htdocs/includes/OAuth/Common/Http/Client/StreamClient.php index e91288bbe0b..785bd0d603a 100644 --- a/htdocs/includes/OAuth/Common/Http/Client/StreamClient.php +++ b/htdocs/includes/OAuth/Common/Http/Client/StreamClient.php @@ -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);