[e3d4e0a] | 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 |
|
---|
| 18 | namespace Google\Service;
|
---|
| 19 |
|
---|
| 20 | use Google\Client;
|
---|
| 21 | use 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 | */
|
---|
| 36 | class Oauth2 extends \Google\Service
|
---|
| 37 | {
|
---|
| 38 | /** See your primary Google Account 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 | public $rootUrlTemplate;
|
---|
| 51 | private $base_methods;
|
---|
| 52 | /**
|
---|
| 53 | * Constructs the internal representation of the Oauth2 service.
|
---|
| 54 | *
|
---|
| 55 | * @param Client|array $clientOrConfig The client used to deliver requests, or a
|
---|
| 56 | * config array to pass to a new Client instance.
|
---|
| 57 | * @param string $rootUrl The root URL used for requests to the service.
|
---|
| 58 | */
|
---|
| 59 | public function __construct($clientOrConfig = [], $rootUrl = null)
|
---|
| 60 | {
|
---|
| 61 | parent::__construct($clientOrConfig);
|
---|
| 62 | $this->rootUrl = $rootUrl ?: 'https://www.googleapis.com/';
|
---|
| 63 | $this->rootUrlTemplate = $rootUrl ?: 'https://www.UNIVERSE_DOMAIN/';
|
---|
| 64 | $this->servicePath = '';
|
---|
| 65 | $this->batchPath = 'batch/oauth2/v2';
|
---|
| 66 | $this->version = 'v2';
|
---|
| 67 | $this->serviceName = 'oauth2';
|
---|
| 68 |
|
---|
| 69 | $this->userinfo = new Oauth2\Resource\Userinfo(
|
---|
| 70 | $this,
|
---|
| 71 | $this->serviceName,
|
---|
| 72 | 'userinfo',
|
---|
| 73 | [
|
---|
| 74 | 'methods' => [
|
---|
| 75 | 'get' => [
|
---|
| 76 | 'path' => 'oauth2/v2/userinfo',
|
---|
| 77 | 'httpMethod' => 'GET',
|
---|
| 78 | 'parameters' => [],
|
---|
| 79 | ],
|
---|
| 80 | ]
|
---|
| 81 | ]
|
---|
| 82 | );
|
---|
| 83 | $this->userinfo_v2_me = new Oauth2\Resource\UserinfoV2Me(
|
---|
| 84 | $this,
|
---|
| 85 | $this->serviceName,
|
---|
| 86 | 'me',
|
---|
| 87 | [
|
---|
| 88 | 'methods' => [
|
---|
| 89 | 'get' => [
|
---|
| 90 | 'path' => 'userinfo/v2/me',
|
---|
| 91 | 'httpMethod' => 'GET',
|
---|
| 92 | 'parameters' => [],
|
---|
| 93 | ],
|
---|
| 94 | ]
|
---|
| 95 | ]
|
---|
| 96 | );
|
---|
| 97 | $this->base_methods = new Resource(
|
---|
| 98 | $this,
|
---|
| 99 | $this->serviceName,
|
---|
| 100 | '',
|
---|
| 101 | [
|
---|
| 102 | 'methods' => [
|
---|
| 103 | 'tokeninfo' => [
|
---|
| 104 | 'path' => 'oauth2/v2/tokeninfo',
|
---|
| 105 | 'httpMethod' => 'POST',
|
---|
| 106 | 'parameters' => [
|
---|
| 107 | 'access_token' => [
|
---|
| 108 | 'location' => 'query',
|
---|
| 109 | 'type' => 'string',
|
---|
| 110 | ],
|
---|
| 111 | 'id_token' => [
|
---|
| 112 | 'location' => 'query',
|
---|
| 113 | 'type' => 'string',
|
---|
| 114 | ],
|
---|
| 115 | ],
|
---|
| 116 | ],
|
---|
| 117 | ]
|
---|
| 118 | ]
|
---|
| 119 | );
|
---|
| 120 | }
|
---|
| 121 | /**
|
---|
| 122 | * (tokeninfo)
|
---|
| 123 | *
|
---|
| 124 | * @param array $optParams Optional parameters.
|
---|
| 125 | *
|
---|
| 126 | * @opt_param string access_token
|
---|
| 127 | * @opt_param string id_token
|
---|
| 128 | * @return Tokeninfo
|
---|
| 129 | * @throws \Google\Service\Exception
|
---|
| 130 | */
|
---|
| 131 | public function tokeninfo($optParams = [])
|
---|
| 132 | {
|
---|
| 133 | $params = [];
|
---|
| 134 | $params = array_merge($params, $optParams);
|
---|
| 135 | return $this->base_methods->call('tokeninfo', [$params], Tokeninfo::class);
|
---|
| 136 | }
|
---|
| 137 | }
|
---|
| 138 |
|
---|
| 139 | // Adding a class alias for backwards compatibility with the previous class name.
|
---|
| 140 | class_alias(Oauth2::class, 'Google_Service_Oauth2');
|
---|