Device Flow Refresh Token

Hi, I'm following the 6/6/2023 reply from John__B; https://community.constantcontact.com/t5/API-Developer-Support/Device-Flow-Refresh-Token/m-p/404332#M14074 and wrote this refresh token function in PHP; function refreshToken($refreshToken, $clientId, $connection) { $ch = curl_init(); // Define endpoint URL $url = 'https://authz.constantcontact.com/oauth2/default/v1/token'; // Set up the POST fields $postData = [ 'refresh_token' => $refreshToken, 'grant_type' => 'refresh_token', 'client_id' => $clientId ]; curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData)); // Set other cURL options curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded')); // Execute and return the response $result = curl_exec($ch); if (curl_errno($ch)) { return 'Error:' . curl_error($ch); } curl_close($ch); $responseData = json_decode($result, true); // Convert the JSON string to an associative array $accessToken = $responseData['access_token']; // Get the access_token value setAuthToken($connection, $accessToken); return $accessToken; } and it returns "The refresh token is invalid or expired". When I get my original token, I receive; {"token_type":"Bearer","expires_in":86400,"access_token":"","scope":"openid contact_data","id_token":"}. Is the refresh token the "id_token"? Is my function correct and I'm receiving the refresh token invalid because I waited too long to refresh my token? Thank you in advance for your help. Best Regards, Brian
1 reply

Leaderboard