Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Differences Between: [Versions 310 and 402] [Versions 311 and 402] [Versions 39 and 402] [Versions 400 and 402] [Versions 401 and 402]

   1  <?php
   2  /*
   3   * Copyright 2010 Google Inc.
   4   *
   5   * Licensed under the Apache License, Version 2.0 (the "License"); you may not
   6   * use this file except in compliance with the License. You may obtain a copy of
   7   * the License at
   8   *
   9   * http://www.apache.org/licenses/LICENSE-2.0
  10   *
  11   * Unless required by applicable law or agreed to in writing, software
  12   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  13   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  14   * License for the specific language governing permissions and limitations under
  15   * the License.
  16   */
  17  
  18  /**
  19   * Service definition for Oauth2 (v2).
  20   *
  21   * <p>
  22   * Lets you access OAuth2 protocol related APIs.</p>
  23   *
  24   * <p>
  25   * For more information about this service, see the API
  26   * <a href="https://developers.google.com/accounts/docs/OAuth2" target="_blank">Documentation</a>
  27   * </p>
  28   *
  29   * @author Google, Inc.
  30   */
  31  #[AllowDynamicProperties]
  32  class Google_Service_Oauth2 extends Google_Service
  33  {
  34    /** Know your basic profile info and list of people in your circles.. */
  35    const PLUS_LOGIN =
  36        "https://www.googleapis.com/auth/plus.login";
  37    /** Know who you are on Google. */
  38    const PLUS_ME =
  39        "https://www.googleapis.com/auth/plus.me";
  40    /** View your email address. */
  41    const USERINFO_EMAIL =
  42        "https://www.googleapis.com/auth/userinfo.email";
  43    /** View your basic profile info. */
  44    const USERINFO_PROFILE =
  45        "https://www.googleapis.com/auth/userinfo.profile";
  46  
  47    public $userinfo;
  48    public $userinfo_v2_me;
  49    private $base_methods;
  50  
  51    /**
  52     * Constructs the internal representation of the Oauth2 service.
  53     *
  54     * @param Google_Client $client
  55     */
  56    public function __construct(Google_Client $client)
  57    {
  58      parent::__construct($client);
  59      $this->rootUrl = 'https://www.googleapis.com/';
  60      $this->servicePath = '';
  61      $this->version = 'v2';
  62      $this->serviceName = 'oauth2';
  63  
  64      $this->userinfo = new Google_Service_Oauth2_Userinfo_Resource(
  65          $this,
  66          $this->serviceName,
  67          'userinfo',
  68          array(
  69            'methods' => array(
  70              'get' => array(
  71                'path' => 'oauth2/v2/userinfo',
  72                'httpMethod' => 'GET',
  73                'parameters' => array(),
  74              ),
  75            )
  76          )
  77      );
  78      $this->userinfo_v2_me = new Google_Service_Oauth2_UserinfoV2Me_Resource(
  79          $this,
  80          $this->serviceName,
  81          'me',
  82          array(
  83            'methods' => array(
  84              'get' => array(
  85                'path' => 'userinfo/v2/me',
  86                'httpMethod' => 'GET',
  87                'parameters' => array(),
  88              ),
  89            )
  90          )
  91      );
  92      $this->base_methods = new Google_Service_Resource(
  93          $this,
  94          $this->serviceName,
  95          '',
  96          array(
  97            'methods' => array(
  98              'getCertForOpenIdConnect' => array(
  99                'path' => 'oauth2/v2/certs',
 100                'httpMethod' => 'GET',
 101                'parameters' => array(),
 102              ),'tokeninfo' => array(
 103                'path' => 'oauth2/v2/tokeninfo',
 104                'httpMethod' => 'POST',
 105                'parameters' => array(
 106                  'access_token' => array(
 107                    'location' => 'query',
 108                    'type' => 'string',
 109                  ),
 110                  'id_token' => array(
 111                    'location' => 'query',
 112                    'type' => 'string',
 113                  ),
 114                  'token_handle' => array(
 115                    'location' => 'query',
 116                    'type' => 'string',
 117                  ),
 118                ),
 119              ),
 120            )
 121          )
 122      );
 123    }
 124    /**
 125     * (getCertForOpenIdConnect)
 126     *
 127     * @param array $optParams Optional parameters.
 128     * @return Google_Service_Oauth2_Jwk
 129     */
 130    public function getCertForOpenIdConnect($optParams = array())
 131    {
 132      $params = array();
 133      $params = array_merge($params, $optParams);
 134      return $this->base_methods->call('getCertForOpenIdConnect', array($params), "Google_Service_Oauth2_Jwk");
 135    }
 136    /**
 137     * (tokeninfo)
 138     *
 139     * @param array $optParams Optional parameters.
 140     *
 141     * @opt_param string access_token
 142     * @opt_param string id_token
 143     * @opt_param string token_handle
 144     * @return Google_Service_Oauth2_Tokeninfo
 145     */
 146    public function tokeninfo($optParams = array())
 147    {
 148      $params = array();
 149      $params = array_merge($params, $optParams);
 150      return $this->base_methods->call('tokeninfo', array($params), "Google_Service_Oauth2_Tokeninfo");
 151    }
 152  }
 153  
 154  
 155  /**
 156   * The "userinfo" collection of methods.
 157   * Typical usage is:
 158   *  <code>
 159   *   $oauth2Service = new Google_Service_Oauth2(...);
 160   *   $userinfo = $oauth2Service->userinfo;
 161   *  </code>
 162   */
 163  #[AllowDynamicProperties]
 164  class Google_Service_Oauth2_Userinfo_Resource extends Google_Service_Resource
 165  {
 166  
 167    /**
 168     * (userinfo.get)
 169     *
 170     * @param array $optParams Optional parameters.
 171     * @return Google_Service_Oauth2_Userinfoplus
 172     */
 173    public function get($optParams = array())
 174    {
 175      $params = array();
 176      $params = array_merge($params, $optParams);
 177      return $this->call('get', array($params), "Google_Service_Oauth2_Userinfoplus");
 178    }
 179  }
 180  
 181  /**
 182   * The "v2" collection of methods.
 183   * Typical usage is:
 184   *  <code>
 185   *   $oauth2Service = new Google_Service_Oauth2(...);
 186   *   $v2 = $oauth2Service->v2;
 187   *  </code>
 188   */
 189  #[AllowDynamicProperties]
 190  class Google_Service_Oauth2_UserinfoV2_Resource extends Google_Service_Resource
 191  {
 192  }
 193  
 194  /**
 195   * The "me" collection of methods.
 196   * Typical usage is:
 197   *  <code>
 198   *   $oauth2Service = new Google_Service_Oauth2(...);
 199   *   $me = $oauth2Service->me;
 200   *  </code>
 201   */
 202  #[AllowDynamicProperties]
 203  class Google_Service_Oauth2_UserinfoV2Me_Resource extends Google_Service_Resource
 204  {
 205  
 206    /**
 207     * (me.get)
 208     *
 209     * @param array $optParams Optional parameters.
 210     * @return Google_Service_Oauth2_Userinfoplus
 211     */
 212    public function get($optParams = array())
 213    {
 214      $params = array();
 215      $params = array_merge($params, $optParams);
 216      return $this->call('get', array($params), "Google_Service_Oauth2_Userinfoplus");
 217    }
 218  }
 219  
 220  
 221  
 222  
 223  #[AllowDynamicProperties]
 224  class Google_Service_Oauth2_Jwk extends Google_Collection
 225  {
 226    protected $collection_key = 'keys';
 227    protected $internal_gapi_mappings = array(
 228    );
 229    protected $keysType = 'Google_Service_Oauth2_JwkKeys';
 230    protected $keysDataType = 'array';
 231  
 232  
 233    public function setKeys($keys)
 234    {
 235      $this->keys = $keys;
 236    }
 237    public function getKeys()
 238    {
 239      return $this->keys;
 240    }
 241  }
 242  
 243  #[AllowDynamicProperties]
 244  class Google_Service_Oauth2_JwkKeys extends Google_Model
 245  {
 246    protected $internal_gapi_mappings = array(
 247    );
 248    public $alg;
 249    public $e;
 250    public $kid;
 251    public $kty;
 252    public $n;
 253    public $use;
 254  
 255  
 256    public function setAlg($alg)
 257    {
 258      $this->alg = $alg;
 259    }
 260    public function getAlg()
 261    {
 262      return $this->alg;
 263    }
 264    public function setE($e)
 265    {
 266      $this->e = $e;
 267    }
 268    public function getE()
 269    {
 270      return $this->e;
 271    }
 272    public function setKid($kid)
 273    {
 274      $this->kid = $kid;
 275    }
 276    public function getKid()
 277    {
 278      return $this->kid;
 279    }
 280    public function setKty($kty)
 281    {
 282      $this->kty = $kty;
 283    }
 284    public function getKty()
 285    {
 286      return $this->kty;
 287    }
 288    public function setN($n)
 289    {
 290      $this->n = $n;
 291    }
 292    public function getN()
 293    {
 294      return $this->n;
 295    }
 296    public function setUse($use)
 297    {
 298      $this->use = $use;
 299    }
 300    public function getUse()
 301    {
 302      return $this->use;
 303    }
 304  }
 305  
 306  #[AllowDynamicProperties]
 307  class Google_Service_Oauth2_Tokeninfo extends Google_Model
 308  {
 309    protected $internal_gapi_mappings = array(
 310          "accessType" => "access_type",
 311          "expiresIn" => "expires_in",
 312          "issuedTo" => "issued_to",
 313          "tokenHandle" => "token_handle",
 314          "userId" => "user_id",
 315          "verifiedEmail" => "verified_email",
 316    );
 317    public $accessType;
 318    public $audience;
 319    public $email;
 320    public $expiresIn;
 321    public $issuedTo;
 322    public $scope;
 323    public $tokenHandle;
 324    public $userId;
 325    public $verifiedEmail;
 326  
 327  
 328    public function setAccessType($accessType)
 329    {
 330      $this->accessType = $accessType;
 331    }
 332    public function getAccessType()
 333    {
 334      return $this->accessType;
 335    }
 336    public function setAudience($audience)
 337    {
 338      $this->audience = $audience;
 339    }
 340    public function getAudience()
 341    {
 342      return $this->audience;
 343    }
 344    public function setEmail($email)
 345    {
 346      $this->email = $email;
 347    }
 348    public function getEmail()
 349    {
 350      return $this->email;
 351    }
 352    public function setExpiresIn($expiresIn)
 353    {
 354      $this->expiresIn = $expiresIn;
 355    }
 356    public function getExpiresIn()
 357    {
 358      return $this->expiresIn;
 359    }
 360    public function setIssuedTo($issuedTo)
 361    {
 362      $this->issuedTo = $issuedTo;
 363    }
 364    public function getIssuedTo()
 365    {
 366      return $this->issuedTo;
 367    }
 368    public function setScope($scope)
 369    {
 370      $this->scope = $scope;
 371    }
 372    public function getScope()
 373    {
 374      return $this->scope;
 375    }
 376    public function setTokenHandle($tokenHandle)
 377    {
 378      $this->tokenHandle = $tokenHandle;
 379    }
 380    public function getTokenHandle()
 381    {
 382      return $this->tokenHandle;
 383    }
 384    public function setUserId($userId)
 385    {
 386      $this->userId = $userId;
 387    }
 388    public function getUserId()
 389    {
 390      return $this->userId;
 391    }
 392    public function setVerifiedEmail($verifiedEmail)
 393    {
 394      $this->verifiedEmail = $verifiedEmail;
 395    }
 396    public function getVerifiedEmail()
 397    {
 398      return $this->verifiedEmail;
 399    }
 400  }
 401  
 402  #[AllowDynamicProperties]
 403  class Google_Service_Oauth2_Userinfoplus extends Google_Model
 404  {
 405    protected $internal_gapi_mappings = array(
 406          "familyName" => "family_name",
 407          "givenName" => "given_name",
 408          "verifiedEmail" => "verified_email",
 409    );
 410    public $email;
 411    public $familyName;
 412    public $gender;
 413    public $givenName;
 414    public $hd;
 415    public $id;
 416    public $link;
 417    public $locale;
 418    public $name;
 419    public $picture;
 420    public $verifiedEmail;
 421  
 422  
 423    public function setEmail($email)
 424    {
 425      $this->email = $email;
 426    }
 427    public function getEmail()
 428    {
 429      return $this->email;
 430    }
 431    public function setFamilyName($familyName)
 432    {
 433      $this->familyName = $familyName;
 434    }
 435    public function getFamilyName()
 436    {
 437      return $this->familyName;
 438    }
 439    public function setGender($gender)
 440    {
 441      $this->gender = $gender;
 442    }
 443    public function getGender()
 444    {
 445      return $this->gender;
 446    }
 447    public function setGivenName($givenName)
 448    {
 449      $this->givenName = $givenName;
 450    }
 451    public function getGivenName()
 452    {
 453      return $this->givenName;
 454    }
 455    public function setHd($hd)
 456    {
 457      $this->hd = $hd;
 458    }
 459    public function getHd()
 460    {
 461      return $this->hd;
 462    }
 463    public function setId($id)
 464    {
 465      $this->id = $id;
 466    }
 467    public function getId()
 468    {
 469      return $this->id;
 470    }
 471    public function setLink($link)
 472    {
 473      $this->link = $link;
 474    }
 475    public function getLink()
 476    {
 477      return $this->link;
 478    }
 479    public function setLocale($locale)
 480    {
 481      $this->locale = $locale;
 482    }
 483    public function getLocale()
 484    {
 485      return $this->locale;
 486    }
 487    public function setName($name)
 488    {
 489      $this->name = $name;
 490    }
 491    public function getName()
 492    {
 493      return $this->name;
 494    }
 495    public function setPicture($picture)
 496    {
 497      $this->picture = $picture;
 498    }
 499    public function getPicture()
 500    {
 501      return $this->picture;
 502    }
 503    public function setVerifiedEmail($verifiedEmail)
 504    {
 505      $this->verifiedEmail = $verifiedEmail;
 506    }
 507    public function getVerifiedEmail()
 508    {
 509      return $this->verifiedEmail;
 510    }
 511  }