1<?php
2/*
3 * Copyright 2014 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
18namespace Google\Service;
19
20use Google\Client;
21use Google\Service\Oauth2\Tokeninfo;
22
23/**
24 * Service definition for Oauth2 (v2).
25 *
26 * <p>
27 * Obtains end-user authorization grants for use with other Google APIs.</p>
28 *
29 * <p>
30 * For more information about this service, see the API
31 * <a href="https://developers.google.com/identity/protocols/oauth2/" target="_blank">Documentation</a>
32 * </p>
33 *
34 * @author Google, Inc.
35 */
36class Oauth2 extends \Google\Service
37{
38  /** View your email address. */
39  const USERINFO_EMAIL =
40      "https://www.googleapis.com/auth/userinfo.email";
41  /** See your personal info, including any personal info you've made publicly available. */
42  const USERINFO_PROFILE =
43      "https://www.googleapis.com/auth/userinfo.profile";
44  /** Associate you with your personal info on Google. */
45  const OPENID =
46      "openid";
47
48  public $userinfo;
49  public $userinfo_v2_me;
50  private $base_methods;
51  /**
52   * Constructs the internal representation of the Oauth2 service.
53   *
54   * @param Client|array $clientOrConfig The client used to deliver requests, or a
55   *                                     config array to pass to a new Client instance.
56   * @param string $rootUrl The root URL used for requests to the service.
57   */
58  public function __construct($clientOrConfig = [], $rootUrl = null)
59  {
60    parent::__construct($clientOrConfig);
61    $this->rootUrl = $rootUrl ?: 'https://www.googleapis.com/';
62    $this->servicePath = '';
63    $this->batchPath = 'batch/oauth2/v2';
64    $this->version = 'v2';
65    $this->serviceName = 'oauth2';
66
67    $this->userinfo = new Oauth2\Resource\Userinfo(
68        $this,
69        $this->serviceName,
70        'userinfo',
71        [
72          'methods' => [
73            'get' => [
74              'path' => 'oauth2/v2/userinfo',
75              'httpMethod' => 'GET',
76              'parameters' => [],
77            ],
78          ]
79        ]
80    );
81    $this->userinfo_v2_me = new Oauth2\Resource\UserinfoV2Me(
82        $this,
83        $this->serviceName,
84        'me',
85        [
86          'methods' => [
87            'get' => [
88              'path' => 'userinfo/v2/me',
89              'httpMethod' => 'GET',
90              'parameters' => [],
91            ],
92          ]
93        ]
94    );
95    $this->base_methods = new Resource(
96        $this,
97        $this->serviceName,
98        '',
99        [
100          'methods' => [
101            'tokeninfo' => [
102              'path' => 'oauth2/v2/tokeninfo',
103              'httpMethod' => 'POST',
104              'parameters' => [
105                'access_token' => [
106                  'location' => 'query',
107                  'type' => 'string',
108                ],
109                'id_token' => [
110                  'location' => 'query',
111                  'type' => 'string',
112                ],
113              ],
114            ],
115          ]
116        ]
117    );
118  }
119  /**
120   * (tokeninfo)
121   *
122   * @param array $optParams Optional parameters.
123   *
124   * @opt_param string access_token
125   * @opt_param string id_token
126   * @return Tokeninfo
127   */
128  public function tokeninfo($optParams = [])
129  {
130    $params = [];
131    $params = array_merge($params, $optParams);
132    return $this->base_methods->call('tokeninfo', [$params], Tokeninfo::class);
133  }
134}
135
136// Adding a class alias for backwards compatibility with the previous class name.
137class_alias(Oauth2::class, 'Google_Service_Oauth2');
138