1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * MoodleNet callback. 19 * 20 * @package core 21 * @copyright 2023 Huong Nguyen <huongnv13@gmail.com> 22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 23 */ 24 25 use core\moodlenet\moodlenet_client; 26 use core\oauth2\api; 27 28 require_once(__DIR__ . '/../config.php'); 29 require_login(); 30 31 // Parameters. 32 $issuerid = required_param('issuerid', PARAM_INT); 33 $error = optional_param('error', '', PARAM_RAW); 34 $message = optional_param('error_description', null, PARAM_RAW); 35 36 // Headers to make it not cacheable. 37 header('Cache-Control: no-cache, must-revalidate'); 38 header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); 39 40 $PAGE->set_context(context_system::instance()); 41 $PAGE->set_url('/admin/moodlenet_oauth2_callback.php'); 42 $PAGE->set_pagelayout('popup'); 43 44 // Wait as long as it takes for this script to finish. 45 core_php_time_limit::raise(); 46 47 $issuer = api::get_issuer($issuerid); 48 $returnurl = new moodle_url('/admin/moodlenet_oauth2_callback.php'); 49 $returnurl->param('issuerid', $issuerid); 50 $returnurl->param('callback', 'yes'); 51 $returnurl->param('sesskey', sesskey()); 52 $oauthclient = api::get_user_oauth_client($issuer, $returnurl, moodlenet_client::API_SCOPE_CREATE_RESOURCE, true); 53 $oauthclient->is_logged_in(); // Will upgrade the auth code to a token. 54 55 echo $OUTPUT->header(); 56 $PAGE->requires->js_call_amd('core/moodlenet/oauth2callback', 'init', [$error, $message]); 57 echo $OUTPUT->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body