'POST', 'datas' => array( 'grant_type' => 'refresh_token', 'refresh_token' => $_SESSION['oauth_refresh_token'], 'client_id' => 'chemindeleau', 'client_secret' => '01fc4587ab1c23ff456e448dab18327a', ), ); $url = "http://oa.dnc.global/oauth/token.php"; $refresh_response = recuperer_url($url,$options); $refresh_status = (int)$refresh_response['status']; if ( $refresh_status == 200 ) { // Enregistrer le jeton d'accès et recommencer $page = json_decode($refresh_response['page'], true); $_SESSION['oauth_access_token'] = $page['access_token']; return ProtectedApi_GET_auto ( $request); // réentrer } else // Demander une nouvelle authentification Authenticate(); } else return false; break; default : // Demander une nouvelle authentification Authenticate(); } return false; } } else { // Demander une nouvelle authentification Authenticate(); } } /** * Demander une nouvelle authentification au serveur OAuth */ function Authenticate() { // Sécurité : Générer un ID de session nouveau à chaque demande d'autorisation @session_regenerate_id(); // Dire à Callback où il faudra reprendre après authentification $_SESSION['oauth_again'] = $_SERVER['REQUEST_URI']; // Interroger Authorize $url = "https://oa.dnc.global/oauth/authorize.php?response_type=code&client_id=" . APPNAME . "&state=" . session_id(); redirige_par_entete($url); }