Enter the refresh token you obtained through the authorisation code flow to obtain a new access token.
Return HTML; } #[HttpPost('/refresh_token')] public function postRefreshToken($response, $request): string { if(!$request->isFormContent()) return 400; $content = $request->getContent(); $csrfp = (string)$content->getParam('csrfp'); if(!$this->csrfp->verifyToken($csrfp)) return 403; $tokenUri = (string)$content->getParam('token_uri'); if(filter_var($tokenUri, FILTER_VALIDATE_URL) === false) { $response->setStatusCode(400); return <<Provided Token URI was not a valid absolute URI.
Return HTML; } $clientId = (string)$content->getParam('client_id'); $clientSecret = (string)$content->getParam('client_secret'); $refreshToken = (string)$content->getParam('refresh_token'); $auth = (string)$content->getParam('auth'); $headers = []; $body = [ 'grant_type' => 'refresh_token', 'refresh_token' => $refreshToken, ]; if($clientSecret === '') $body['client_id'] = $clientId; elseif($auth === 'body' || ($auth !== 'header' && mt_rand(0, 10) > 5)) { $body['client_id'] = $clientId; $body['client_secret'] = $clientSecret; } else $headers[] = sprintf('Authorization: Basic %s', base64_encode(sprintf('%s:%s', $clientId, $clientSecret))); $body = Tools::shuffleArray($body); $response = Tools::fetch($tokenUri, headers: $headers, body: $body); $tokenUri = htmlspecialchars($tokenUri); $headers = htmlspecialchars(json_encode($headers, JSON_PRETTY_PRINT)); $body = htmlspecialchars(json_encode($body, JSON_PRETTY_PRINT)); $decoded = json_decode($response); if($decoded !== null) $response = json_encode($decoded, JSON_PRETTY_PRINT); $response = htmlspecialchars($response); return <<Below is the request and response data from your request token result. If the response contains a refresh_token field, you can restart the Refresh token flow again and again and again and again!