Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 311 and 402] [Versions 311 and 403]

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