|
15 | 15 | use Bitrix24\Exceptions\Bitrix24BadGatewayException; |
16 | 16 | use Bitrix24\Exceptions\Bitrix24EmptyResponseException; |
17 | 17 | use Bitrix24\Exceptions\Bitrix24Exception; |
| 18 | +use Bitrix24\Exceptions\Bitrix24InsufficientScope; |
18 | 19 | use Bitrix24\Exceptions\Bitrix24IoException; |
19 | 20 | use Bitrix24\Exceptions\Bitrix24MethodNotFoundException; |
20 | 21 | use Bitrix24\Exceptions\Bitrix24PaymentRequiredException; |
|
24 | 25 | use Bitrix24\Exceptions\Bitrix24TokenIsExpiredException; |
25 | 26 | use Bitrix24\Exceptions\Bitrix24TokenIsInvalidException; |
26 | 27 | use Bitrix24\Exceptions\Bitrix24WrongClientException; |
27 | | -use Bitrix24\Exceptions\Bitrix24InsufficientScope; |
28 | 28 | use Psr\Log\LoggerInterface; |
29 | 29 | use Psr\Log\NullLogger; |
30 | 30 |
|
@@ -270,23 +270,15 @@ public function getNewAccessToken() |
270 | 270 | throw new Bitrix24Exception('application redirect URI not found, you must call setRedirectUri method before'); |
271 | 271 | } |
272 | 272 |
|
273 | | -// $url = 'https://'.self::OAUTH_SERVER.'/oauth/token/' |
274 | | - $url = 'https://' . $this->getDomain() . '/oauth/token/' |
| 273 | + $url = 'https://' . self::OAUTH_SERVER . '/oauth/token/' |
275 | 274 | . '?grant_type=refresh_token' |
276 | 275 | . '&client_id=' . urlencode($applicationId) |
277 | 276 | . '&client_secret=' . $applicationSecret |
278 | 277 | . '&refresh_token=' . $refreshToken |
279 | | - . '&scope=' . implode(',', $applicationScope) |
280 | | - . '&redirect_uri=' . urlencode($redirectUri) |
281 | 278 | ; |
282 | 279 |
|
283 | | - var_dump($url); |
284 | | - |
285 | | - |
286 | 280 | $requestResult = $this->executeRequest($url); |
287 | 281 |
|
288 | | - var_dump($requestResult); |
289 | | - |
290 | 282 | // handling bitrix24 api-level errors |
291 | 283 | $this->handleBitrix24APILevelErrors($requestResult, 'refresh access token'); |
292 | 284 |
|
@@ -850,13 +842,11 @@ public function getFirstAccessToken($code) |
850 | 842 | throw new Bitrix24Exception('application redirect URI not found, you must call setRedirectUri method before'); |
851 | 843 | } |
852 | 844 |
|
853 | | -// $url = 'https://'.self::OAUTH_SERVER.'/oauth/token/' |
854 | | - $url = 'https://' . $this->getDomain() . '/oauth/token/' |
| 845 | + $url = 'https://' . self::OAUTH_SERVER . '/oauth/token/' |
855 | 846 | . '?grant_type=authorization_code' |
856 | 847 | . '&client_id=' . urlencode($applicationId) |
857 | 848 | . '&client_secret=' . $applicationSecret |
858 | 849 | . '&code=' . urlencode($code) |
859 | | - . '&redirect_uri=' . urlencode($redirectUri) |
860 | 850 | ; |
861 | 851 |
|
862 | 852 | $requestResult = $this->executeRequest($url); |
@@ -895,9 +885,9 @@ public function isAccessTokenExpire() |
895 | 885 | } elseif (null === $accessToken) { |
896 | 886 | throw new Bitrix24Exception('application id not found, you must call setAccessToken method before'); |
897 | 887 | } |
898 | | -// $url = 'https://'.self::OAUTH_SERVER.'/rest/app.info?auth='.$accessToken; |
899 | | - $url = 'https://' . $domain . '/rest/app.info?auth=' . $accessToken; |
| 888 | + $url = 'https://' . self::OAUTH_SERVER . '/rest/app.info?auth=' . $accessToken; |
900 | 889 | $requestResult = $this->executeRequest($url); |
| 890 | + |
901 | 891 | if (isset($requestResult['error'])) { |
902 | 892 | if (in_array($requestResult['error'], array('expired_token', 'invalid_token', 'WRONG_TOKEN'), false)) { |
903 | 893 | $isTokenExpire = true; |
@@ -1182,8 +1172,6 @@ protected function _call($methodName, array $additionalParameters = array()) |
1182 | 1172 | $isSecureCall = true; |
1183 | 1173 | } |
1184 | 1174 |
|
1185 | | - echo '<pre>params '; print_r($additionalParameters); echo '</pre>'; |
1186 | | - |
1187 | 1175 | // execute request |
1188 | 1176 | $this->log->info('call bitrix24 method', array( |
1189 | 1177 | 'BITRIX24_DOMAIN' => $this->domain, |
@@ -1214,18 +1202,12 @@ protected function _call($methodName, array $additionalParameters = array()) |
1214 | 1202 | // compare signatures |
1215 | 1203 | $hash = hash_hmac('sha256', $dataToDecode, $key, true); |
1216 | 1204 |
|
1217 | | - echo '<pre>result '; print_r($requestResult); echo '</pre>'; |
1218 | | - echo '<pre>hash '; print_r($hash); echo '</pre>'; |
1219 | | - echo '<pre>signature '; print_r($signature); echo '</pre>'; |
1220 | | - |
1221 | 1205 | if ($hash !== $signature) { |
1222 | 1206 | throw new Bitrix24SecurityException('security signatures not same, bad request'); |
1223 | 1207 | } |
1224 | 1208 | // decode |
1225 | 1209 | $arClearData = json_decode(base64_decode($dataToDecode), true); |
1226 | 1210 |
|
1227 | | - echo '<pre>arClearData '; print_r($arClearData); echo '</pre>'; |
1228 | | - |
1229 | 1211 | // handling json_decode errors |
1230 | 1212 | $jsonErrorCode = json_last_error(); |
1231 | 1213 | if (null === $arClearData && (JSON_ERROR_NONE !== $jsonErrorCode)) { |
|
0 commit comments