|
3 | 3 | exit; //Exit if accessed directly |
4 | 4 | } |
5 | 5 |
|
| 6 | +// Durée de validité du refresh token : 30 jours en secondes |
| 7 | +define('HELLOASSO_REFRESH_TOKEN_LIFETIME', 30 * 24 * 60 * 60); // 2592000 secondes |
| 8 | + |
6 | 9 | function helloasso_get_oauth_token($client_id, $client_secret, $api_url) |
7 | 10 | { |
8 | 11 | helloasso_log_debug('Vérification du token OAuth2', array( |
@@ -59,8 +62,8 @@ function helloasso_get_oauth_token($client_id, $client_secret, $api_url) |
59 | 62 | if (isset($data->access_token)) { |
60 | 63 | update_option('helloasso_access_token', $data->access_token); |
61 | 64 | update_option('helloasso_refresh_token', $data->refresh_token); |
62 | | - update_option('helloasso_token_expires_in', $data->expires_in); |
63 | | - update_option('helloasso_refresh_token_expires_in', time() + 2629800); |
| 65 | + update_option('helloasso_token_expires_in', time() + $data->expires_in); |
| 66 | + update_option('helloasso_refresh_token_expires_in', time() + HELLOASSO_REFRESH_TOKEN_LIFETIME); |
64 | 67 |
|
65 | 68 | helloasso_log_info('Token OAuth2 rafraîchi avec succès', array( |
66 | 69 | 'new_token_preview' => substr($data->access_token, 0, 10) . '...', |
@@ -112,8 +115,8 @@ function helloasso_get_oauth_token($client_id, $client_secret, $api_url) |
112 | 115 | if (isset($data->access_token)) { |
113 | 116 | add_option('helloasso_access_token', $data->access_token); |
114 | 117 | add_option('helloasso_refresh_token', $data->refresh_token); |
115 | | - add_option('helloasso_token_expires_in', $data->expires_in); |
116 | | - add_option('helloasso_refresh_token_expires_in', time() + 2629800); |
| 118 | + add_option('helloasso_token_expires_in', time() + $data->expires_in); |
| 119 | + add_option('helloasso_refresh_token_expires_in', time() + HELLOASSO_REFRESH_TOKEN_LIFETIME); |
117 | 120 |
|
118 | 121 | helloasso_log_info('Nouveau token OAuth2 obtenu avec succès', array( |
119 | 122 | 'token_preview' => substr($data->access_token, 0, 10) . '...', |
|
0 commit comments