Skip to content

Commit

Permalink
upgraded google api
Browse files Browse the repository at this point in the history
upgraded google api
  • Loading branch information
taoteh1221 committed Oct 10, 2021
1 parent 986df30 commit 646ba71
Show file tree
Hide file tree
Showing 14,973 changed files with 1,208,962 additions and 29,718 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
149 changes: 115 additions & 34 deletions app-lib/php/classes/3rd-party/google-api/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
[![Build Status](https://travis-ci.org/googleapis/google-api-php-client.svg?branch=master)](https://travis-ci.org/googleapis/google-api-php-client)
![](https://github.com/googleapis/google-api-php-client/workflows/.github/workflows/tests.yml/badge.svg)

# Google APIs Client Library for PHP #

The Google API Client Library enables you to work with Google APIs such as Google+, Drive, or YouTube on your server.
<dl>
<dt>Reference Docs</dt><dd><a href="https://googleapis.github.io/google-api-php-client/master/">https://googleapis.github.io/google-api-php-client/master/</a></dd>
<dt>License</dt><dd>Apache 2.0</dd>
</dl>

These client libraries are officially supported by Google. However, the libraries are considered complete and are in maintenance mode. This means that we will address critical bugs and security issues but will not add any new features.
The Google API Client Library enables you to work with Google APIs such as Gmail, Drive or YouTube on your server.

**NOTE** The actively maintained (v2) version of this client requires PHP 5.4 or above. If you require support for PHP 5.2 or 5.3, use the v1 branch.
These client libraries are officially supported by Google. However, the libraries are considered complete and are in maintenance mode. This means that we will address critical bugs and security issues but will not add any new features.

## Google Cloud Platform

For Google Cloud Platform APIs such as Datastore, Cloud Storage or Pub/Sub, we recommend using [GoogleCloudPlatform/google-cloud-php](https://github.com/googleapis/google-cloud-php) which is under active development.
For Google Cloud Platform APIs such as [Datastore][cloud-datastore], [Cloud Storage][cloud-storage], [Pub/Sub][cloud-pubsub], and [Compute Engine][cloud-compute], we recommend using the Google Cloud client libraries. For a complete list of supported Google Cloud client libraries, see [googleapis/google-cloud-php](https://github.com/googleapis/google-cloud-php).

[cloud-datastore]: https://github.com/googleapis/google-cloud-php-datastore
[cloud-pubsub]: https://github.com/googleapis/google-cloud-php-pubsub
[cloud-storage]: https://github.com/googleapis/google-cloud-php-storage
[cloud-compute]: https://github.com/googleapis/google-cloud-php-compute

## Requirements ##
* [PHP 5.4.0 or higher](https://www.php.net/)
* [PHP 5.6.0 or higher](https://www.php.net/)

## Developer Documentation ##

Expand All @@ -32,7 +40,7 @@ composer installed.
Once composer is installed, execute the following command in your project root to install this library:

```sh
composer require google/apiclient:"^2.0"
composer require google/apiclient:^2.11
```

Finally, be sure to include the autoloader:
Expand All @@ -41,6 +49,61 @@ Finally, be sure to include the autoloader:
require_once '/path/to/your-project/vendor/autoload.php';
```

This library relies on `google/apiclient-services`. That library provides up-to-date API wrappers for a large number of Google APIs. In order that users may make use of the latest API clients, this library does not pin to a specific version of `google/apiclient-services`. **In order to prevent the accidental installation of API wrappers with breaking changes**, it is highly recommended that you pin to the [latest version](https://github.com/googleapis/google-api-php-client-services/releases) yourself prior to using this library in production.

#### Cleaning up unused services

There are over 200 Google API services. The chances are good that you will not
want them all. In order to avoid shipping these dependencies with your code,
you can run the `Google\Task\Composer::cleanup` task and specify the services
you want to keep in `composer.json`:

```json
{
"require": {
"google/apiclient": "^2.11"
},
"scripts": {
"pre-autoload-dump": "Google\\Task\\Composer::cleanup"
},
"extra": {
"google/apiclient-services": [
"Drive",
"YouTube"
]
}
}
```

This example will remove all services other than "Drive" and "YouTube" when
`composer update` or a fresh `composer install` is run.

**IMPORTANT**: If you add any services back in `composer.json`, you will need to
remove the `vendor/google/apiclient-services` directory explicity for the
change you made to have effect:

```sh
rm -r vendor/google/apiclient-services
composer update
```

**NOTE**: This command performs an exact match on the service name, so to keep
`YouTubeReporting` and `YouTubeAnalytics` as well, you'd need to add each of
them explicitly:

```json
{
"extra": {
"google/apiclient-services": [
"Drive",
"YouTube",
"YouTubeAnalytics",
"YouTubeReporting"
]
}
}
```

### Download the Release

If you prefer not to use composer, you can download the package in its entirety. The [Releases](https://github.com/googleapis/google-api-php-client/releases) page lists all stable versions. Download any file
Expand Down Expand Up @@ -71,15 +134,18 @@ And then browsing to the host and port you specified
// include your composer dependencies
require_once 'vendor/autoload.php';

$client = new Google_Client();
$client = new Google\Client();
$client->setApplicationName("Client_Library_Examples");
$client->setDeveloperKey("YOUR_APP_KEY");

$service = new Google_Service_Books($client);
$optParams = array('filter' => 'free-ebooks');
$results = $service->volumes->listVolumes('Henry David Thoreau', $optParams);
$service = new Google\Service\Books($client);
$query = 'Henry David Thoreau';
$optParams = [
'filter' => 'free-ebooks',
];
$results = $service->volumes->listVolumes($query, $optParams);

foreach ($results as $item) {
foreach ($results->getItems() as $item) {
echo $item['volumeInfo']['title'], "<br /> \n";
}
```
Expand All @@ -90,17 +156,17 @@ foreach ($results as $item) {
1. Follow the instructions to [Create Web Application Credentials](docs/oauth-web.md#create-authorization-credentials)
1. Download the JSON credentials
1. Set the path to these credentials using `Google_Client::setAuthConfig`:
1. Set the path to these credentials using `Google\Client::setAuthConfig`:

```php
$client = new Google_Client();
$client = new Google\Client();
$client->setAuthConfig('/path/to/client_credentials.json');
```

1. Set the scopes required for the API you are going to call

```php
$client->addScope(Google_Service_Drive::DRIVE);
$client->addScope(Google\Service\Drive::DRIVE);
```

1. Set your application's redirect URI
Expand Down Expand Up @@ -140,14 +206,14 @@ calls return unexpected 401 or 403 errors.
1. Tell the Google client to use your service account credentials to authenticate:

```php
$client = new Google_Client();
$client = new Google\Client();
$client->useApplicationDefaultCredentials();
```

1. Set the scopes required for the API you are going to call

```php
$client->addScope(Google_Service_Drive::DRIVE);
$client->addScope(Google\Service\Drive::DRIVE);
```

1. If you have delegated domain-wide access to the service account and you want to impersonate a user account, specify the email address of the user account using the method setSubject:
Expand All @@ -156,6 +222,19 @@ calls return unexpected 401 or 403 errors.
$client->setSubject($user_to_impersonate);
```

#### How to use a specific JSON key

If you want to a specific JSON key instead of using `GOOGLE_APPLICATION_CREDENTIALS` environment variable, you can do this:

```php
$jsonKey = [
'type' => 'service_account',
// ...
];
$client = new Google\Client();
$client->setAuthConfig($jsonKey);
```

### Making Requests ###

The classes used to call the API in [google-api-php-client-services](https://github.com/googleapis/google-api-php-client-services) are autogenerated. They map directly to the JSON requests and responses found in the [APIs Explorer](https://developers.google.com/apis-explorer/#p/).
Expand Down Expand Up @@ -185,10 +264,10 @@ Using this library, the same call would look something like this:

```php
// create the datastore service class
$datastore = new Google_Service_Datastore($client);
$datastore = new Google\Service\Datastore($client);

// build the query - this maps directly to the JSON
$query = new Google_Service_Datastore_Query([
$query = new Google\Service\Datastore\Query([
'kind' => [
[
'name' => 'Book',
Expand All @@ -204,28 +283,28 @@ $query = new Google_Service_Datastore_Query([
]);

// build the request and response
$request = new Google_Service_Datastore_RunQueryRequest(['query' => $query]);
$request = new Google\Service\Datastore\RunQueryRequest(['query' => $query]);
$response = $datastore->projects->runQuery('YOUR_DATASET_ID', $request);
```

However, as each property of the JSON API has a corresponding generated class, the above code could also be written like this:

```php
// create the datastore service class
$datastore = new Google_Service_Datastore($client);
$datastore = new Google\Service\Datastore($client);

// build the query
$request = new Google_Service_Datastore_RunQueryRequest();
$query = new Google_Service_Datastore_Query();
$request = new Google\Service\Datastore_RunQueryRequest();
$query = new Google\Service\Datastore\Query();
// - set the order
$order = new Google_Service_Datastore_PropertyOrder();
$order = new Google\Service\Datastore_PropertyOrder();
$order->setDirection('descending');
$property = new Google_Service_Datastore_PropertyReference();
$property = new Google\Service\Datastore\PropertyReference();
$property->setName('title');
$order->setProperty($property);
$query->setOrder([$order]);
// - set the kinds
$kind = new Google_Service_Datastore_KindExpression();
$kind = new Google\Service\Datastore\KindExpression();
$kind->setName('Book');
$query->setKinds([$kind]);
// - set the limit
Expand All @@ -242,19 +321,21 @@ The method used is a matter of preference, but *it will be very difficult to use

If Google Authentication is desired for external applications, or a Google API is not available yet in this library, HTTP requests can be made directly.

If you are installing this client only to authenticate your own HTTP client requests, you should use [`google/auth`](https://github.com/googleapis/google-auth-library-php#call-the-apis) instead.

The `authorize` method returns an authorized [Guzzle Client](http://docs.guzzlephp.org/), so any request made using the client will contain the corresponding authorization.

```php
// create the Google client
$client = new Google_Client();
$client = new Google\Client();

/**
* Set your method for authentication. Depending on the API, This could be
* directly with an access token, API key, or (recommended) using
* Application Default Credentials.
*/
$client->useApplicationDefaultCredentials();
$client->addScope(Google_Service_Plus::PLUS_ME);
$client->addScope(Google\Service\Plus::PLUS_ME);

// returns a Guzzle HTTP Client
$httpClient = $client->authorize();
Expand Down Expand Up @@ -290,7 +371,7 @@ composer require cache/filesystem-adapter
When using [Refresh Tokens](https://developers.google.com/identity/protocols/OAuth2InstalledApp#offline) or [Service Account Credentials](https://developers.google.com/identity/protocols/OAuth2ServiceAccount#overview), it may be useful to perform some action when a new access token is granted. To do this, pass a callable to the `setTokenCallback` method on the client:

```php
$logger = new Monolog\Logger;
$logger = new Monolog\Logger();
$tokenCallback = function ($cacheKey, $accessToken) use ($logger) {
$logger->debug(sprintf('new access token received at cache key %s', $cacheKey));
};
Expand All @@ -308,7 +389,7 @@ $httpClient = new GuzzleHttp\Client([
'verify' => false, // otherwise HTTPS requests will fail.
]);

$client = new Google_Client();
$client = new Google\Client();
$client->setHttpClient($httpClient);
```

Expand All @@ -331,7 +412,7 @@ $httpClient = new Client([
]
]);

$client = new Google_Client();
$client = new Google\Client();
$client->setHttpClient($httpClient);
```

Expand All @@ -357,9 +438,9 @@ If there is a specific bug with the library, please [file an issue](https://gith

If X is a feature of the library, file away! If X is an example of using a specific service, the best place to go is to the teams for those specific APIs - our preference is to link to their examples rather than add them to the library, as they can then pin to specific versions of the library. If you have any examples for other APIs, let us know and we will happily add a link to the README above!

### Why does Google_..._Service have weird names? ###
### Why do some Google\Service classes have weird names? ###

The _Service classes are generally automatically generated from the API discovery documents: https://developers.google.com/discovery/. Sometimes new features are added to APIs with unusual names, which can cause some unexpected or non-standard style naming in the PHP classes.
The _Google\Service_ classes are generally automatically generated from the API discovery documents: https://developers.google.com/discovery/. Sometimes new features are added to APIs with unusual names, which can cause some unexpected or non-standard style naming in the PHP classes.

### How do I deal with non-JSON response types? ###

Expand All @@ -373,7 +454,7 @@ $opt_params = array(

### How do I set a field to null? ###

The library strips out nulls from the objects sent to the Google APIs as its the default value of all of the uninitialized properties. To work around this, set the field you want to null to `Google_Model::NULL_VALUE`. This is a placeholder that will be replaced with a true null when sent over the wire.
The library strips out nulls from the objects sent to the Google APIs as its the default value of all of the uninitialized properties. To work around this, set the field you want to null to `Google\Model::NULL_VALUE`. This is a placeholder that will be replaced with a true null when sent over the wire.

## Code Quality ##

Expand Down
7 changes: 7 additions & 0 deletions app-lib/php/classes/3rd-party/google-api/SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Security Policy

To report a security issue, please use [g.co/vulnz](https://g.co/vulnz).

The Google Security Team will respond within 5 working days of your report on g.co/vulnz.

We use g.co/vulnz for our intake, and do coordination and disclosure here using GitHub Security Advisory to privately discuss and fix the issue.

0 comments on commit 646ba71

Please sign in to comment.