I'm having ongoing troubles with refresh tokens. I can refresh as much as I want when testing, but the second the access token actually expires and triggers my app to refresh the tokens, the refresh token fails to work. This is the message I get back when the access token expires and I attempt to refresh it: {"error_description":"unknown, invalid, or expired refresh token","error":"invalid_grant"} This is the code (which again, works when testing it): function constantContactRefreshToken($foundation = false) {
global $apiAuthentication;
$clientId = $apiAuthentication['clientId'];
$clientSecret = $apiAuthentication['clientSecret'];
$ch = curl_init();
$refreshToken = get_option('constant_contact_refresh');
$url = 'https://idfed.constantcontact.com/as/token.oauth2?refresh_token=' . $refreshToken . '&grant_type=refresh_token';
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Authorization: Basic ' . base64_encode($clientId . ':' . $clientSecret)
));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
Logging::log('constantContactRefreshToken', array('response' => $response, 'foundation' => $foundation, 'refreshToken' => $refreshToken));
curl_close($ch);
try {
$response = json_decode($response);
if ($response->access_token) {
update_option('constant_contact_access', $response->access_token);
}
if ($response->refresh_token) {
update_option('constant_contact_refresh', $response->refresh_token);
}
} catch (Exception $e) {}
} Am I supposed to be refreshing the token every time I use it? The docs say the refresh token doesn't expire, but it certainly seems like it is.
... View more