Differences Between: [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]
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 namespace core\oauth2\client; 18 19 use core\oauth2\client; 20 21 /** 22 * Class linkedin - Custom client handler to fetch data from linkedin 23 * 24 * Custom oauth2 client for linkedin as it doesn't support OIDC and has a different way to get 25 * key information for users - firstname, lastname, email. 26 * 27 * @copyright 2021 Peter Dias 28 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 29 * @package core 30 */ 31 class linkedin extends client { 32 /** 33 * Fetch the user info from the userinfo and email endpoint and map fields back 34 * 35 * @return array|false 36 */ 37 public function get_userinfo() { 38 $user = array_merge(parent::get_userinfo(), $this->get_useremail()); 39 return $user; 40 } 41 42 /** 43 * Get the email address of the user from the email endpoint 44 * 45 * @return array|false 46 */ 47 private function get_useremail() { 48 $url = $this->get_issuer()->get_endpoint_url('email'); 49 50 $response = $this->get($url); 51 if (!$response) { 52 return false; 53 } 54 $userinfo = new \stdClass(); 55 try { 56 $userinfo = json_decode($response); 57 } catch (\Exception $e) { 58 return false; 59 } 60 61 return $this->map_userinfo_to_fields($userinfo); 62 } 63 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body