Skip to content

Commit 9d1953b

Browse files
authored
Merge branch 'main' into update-libver
2 parents ae2d774 + 7bb27a5 commit 9d1953b

13 files changed

Lines changed: 81 additions & 59 deletions

File tree

.github/CODEOWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44
# For syntax help see:
55
# https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax
66

7-
* @googleapis/yoshi-php
7+
* @googleapis/cloud-sdk-php-team
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
always_check_pr_title: true
2+

.github/sync-repo-settings.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,5 @@ branchProtectionRules:
1818
requiresCodeOwnerReviews: true
1919
requiresStrictStatusChecks: true
2020
permissionRules:
21-
- team: yoshi-php-admins
22-
permission: admin
23-
- team: yoshi-php
21+
- team: cloud-sdk-php-team
2422
permission: push

.github/workflows/asset-release.yml

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,34 @@
11
name: Add Release Assets
22

3+
permissions:
4+
contents: write
5+
36
on:
47
release:
58
types: [published]
69
workflow_dispatch:
7-
10+
inputs:
11+
tag:
12+
description: 'Tag to generate documentation for'
13+
required: true
14+
upload-on-workflow-dispatch:
15+
description: 'Upload assets?'
16+
required: false
17+
default: "false"
818
jobs:
919
asset:
1020
runs-on: ${{ matrix.operating-system }}
1121
strategy:
1222
matrix:
1323
operating-system: [ ubuntu-latest ]
14-
php: [ "8.0", "8.3" ]
24+
php: [ "8.1", "8.3" ]
1525

1626
name: Upload Release Assets
1727
steps:
1828
- id: getTag
1929
name: Get Tag
2030
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
2131

22-
- name: Get release
23-
id: get_release
24-
uses: bruceadams/get-release@v1.2.2
25-
env:
26-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27-
2832
- name: Checkout
2933
uses: actions/checkout@v2
3034

@@ -51,14 +55,12 @@ jobs:
5155
zip -d ${fileName} "tests*" || true &&
5256
zip -d ${fileName} "examples*" || true
5357
env:
54-
fileName: google-api-php-client-${{ steps.tagName.outputs.tag }}-PHP${{ matrix.php }}.zip
58+
fileName: google-api-php-client-${{ inputs.tag || steps.tagName.outputs.tag }}-PHP${{ matrix.php }}.zip
5559

5660
- name: Upload Release Archive
57-
uses: actions/upload-release-asset@v1
58-
env:
59-
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
61+
uses: softprops/action-gh-release@v2
62+
if: github.ref_type == 'tag' || inputs.upload-on-workflow-dispatch == 'true'
6063
with:
61-
upload_url: ${{ steps.get_release.outputs.upload_url }}
62-
asset_path: ./google-api-php-client-${{ steps.tagName.outputs.tag }}-PHP${{ matrix.php }}.zip
63-
asset_name: google-api-php-client-${{ steps.tagName.outputs.tag }}-PHP${{ matrix.php }}.zip
64-
asset_content_type: application/zip
64+
tag_name: ${{ inputs.tag || steps.tagName.outputs.tag }}
65+
files: |
66+
./google-api-php-client-${{ inputs.tag || steps.tagName.outputs.tag }}-PHP${{ matrix.php }}.zip

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
php: [ "8.0", "8.1", "8.2", "8.3", "8.4" ]
14+
php: [ "8.1", "8.2", "8.3", "8.4" ]
1515
composer-flags: [""]
1616
include:
17-
- php: "8.0"
17+
- php: "8.1"
1818
composer-flags: "--prefer-lowest "
1919
- php: "8.4"
2020
composer-flags: "--prefer-lowest "

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
# Changelog
22

3+
## [2.19.0](https://github.com/googleapis/google-api-php-client/compare/v2.18.4...v2.19.0) (2026-01-09)
4+
5+
6+
### Features
7+
8+
* Support firebase/php-jwt version 6.0 and 7.0 ([#2696](https://github.com/googleapis/google-api-php-client/issues/2696)) ([70ea42a](https://github.com/googleapis/google-api-php-client/commit/70ea42a6aa29a1321825c3dcda39cf39174390ea))
9+
10+
11+
### Bug Fixes
12+
13+
* Upload assets release job ([#2671](https://github.com/googleapis/google-api-php-client/issues/2671)) ([0f56ea7](https://github.com/googleapis/google-api-php-client/commit/0f56ea773cb51cc6131c442d112d7fd630b49b5c))
14+
15+
## [2.18.4](https://github.com/googleapis/google-api-php-client/compare/v2.18.3...v2.18.4) (2025-09-29)
16+
17+
18+
### Bug Fixes
19+
20+
* Ensure credentials can be of type FetchAuthTokenInterface ([#2684](https://github.com/googleapis/google-api-php-client/issues/2684)) ([ed70802](https://github.com/googleapis/google-api-php-client/commit/ed70802cc4886ef1f513a2c0b56a8a972db5e7ab))
21+
322
## [2.18.3](https://github.com/googleapis/google-api-php-client/compare/v2.18.2...v2.18.3) (2025-04-08)
423

524

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
"homepage": "http://developers.google.com/api-client-library/php",
77
"license": "Apache-2.0",
88
"require": {
9-
"php": "^8.0",
9+
"php": "^8.1",
1010
"google/auth": "^1.37",
1111
"google/apiclient-services": "~0.350",
12-
"firebase/php-jwt": "^6.0",
12+
"firebase/php-jwt": "^6.0||^7.0",
1313
"monolog/monolog": "^2.9||^3.0",
14-
"phpseclib/phpseclib": "^3.0.36",
14+
"phpseclib/phpseclib": "^3.0.50",
1515
"guzzlehttp/guzzle": "^7.4.5",
1616
"guzzlehttp/psr7": "^2.6"
1717
},
@@ -21,7 +21,7 @@
2121
"symfony/css-selector": "~2.1",
2222
"cache/filesystem-adapter": "^1.1",
2323
"phpcompatibility/php-compatibility": "^9.2",
24-
"composer/composer": "^1.10.23",
24+
"composer/composer": "^2.9",
2525
"phpspec/prophecy-phpunit": "^2.1",
2626
"phpunit/phpunit": "^9.6"
2727
},

docs/oauth-web.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,10 @@ After completing the OAuth 2.0 flow, you should be redirected to `http://localho
258258

259259
After the web server receives the authorization code, it can exchange the authorization code for an access token.
260260

261-
To exchange an authorization code for an access token, use the `authenticate` method:
261+
To exchange an authorization code for an access token, use the `fetchAccessTokenWithAuthCode` method:
262262

263263
```php
264-
$client->authenticate($_GET['code']);
264+
$client->fetchAccessTokenWithAuthCode($_GET['code']);
265265
```
266266

267267
You can retrieve the access token with the `getAccessToken` method:
@@ -353,15 +353,15 @@ require_once __DIR__.'/vendor/autoload.php';
353353
session_start();
354354
355355
$client = new Google\Client();
356-
$client->setAuthConfigFile('client_secrets.json');
356+
$client->setAuthConfig('client_secrets.json');
357357
$client->setRedirectUri('http://' . $_SERVER['HTTP_HOST'] . '/oauth2callback.php');
358358
$client->addScope(Google\Service\Drive::DRIVE_METADATA_READONLY);
359359
360360
if (! isset($_GET['code'])) {
361361
$auth_url = $client->createAuthUrl();
362362
header('Location: ' . filter_var($auth_url, FILTER_SANITIZE_URL));
363363
} else {
364-
$client->authenticate($_GET['code']);
364+
$client->fetchAccessTokenWithAuthCode($_GET['code']);
365365
$_SESSION['access_token'] = $client->getAccessToken();
366366
$redirect_uri = 'http://' . $_SERVER['HTTP_HOST'] . '/';
367367
header('Location: ' . filter_var($redirect_uri, FILTER_SANITIZE_URL));
@@ -421,4 +421,4 @@ $client->revokeToken();
421421
422422
**Note:** Following a successful revocation response, it might take some time before the revocation has full effect.
423423
424-
Except as otherwise noted, the content of this page is licensed under the [Creative Commons Attribution 4.0 License](https://creativecommons.org/licenses/by/4.0/), and code samples are licensed under the [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0). For details, see our [Site Policies](https://developers.google.com/terms/site-policies). Java is a registered trademark of Oracle and/or its affiliates.
424+
Except as otherwise noted, the content of this page is licensed under the [Creative Commons Attribution 4.0 License](https://creativecommons.org/licenses/by/4.0/), and code samples are licensed under the [Apache 2.0 License](https://www.apache.org/licenses/LICENSE-2.0). For details, see our [Site Policies](https://developers.google.com/terms/site-policies). Java is a registered trademark of Oracle and/or its affiliates.

src/AuthHandler/Guzzle6AuthHandler.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace Google\AuthHandler;
44

5-
use Google\Auth\CredentialsLoader;
65
use Google\Auth\FetchAuthTokenCache;
6+
use Google\Auth\FetchAuthTokenInterface;
77
use Google\Auth\HttpHandler\HttpHandlerFactory;
88
use Google\Auth\Middleware\AuthTokenMiddleware;
99
use Google\Auth\Middleware\ScopedAccessTokenMiddleware;
@@ -28,7 +28,7 @@ public function __construct(?CacheItemPoolInterface $cache = null, array $cacheC
2828

2929
public function attachCredentials(
3030
ClientInterface $http,
31-
CredentialsLoader $credentials,
31+
FetchAuthTokenInterface $credentials,
3232
?callable $tokenCallback = null
3333
) {
3434
// use the provided cache
@@ -40,13 +40,21 @@ public function attachCredentials(
4040
);
4141
}
4242

43-
return $this->attachCredentialsCache($http, $credentials, $tokenCallback);
43+
return $this->attachToHttp($http, $credentials, $tokenCallback);
4444
}
4545

4646
public function attachCredentialsCache(
4747
ClientInterface $http,
4848
FetchAuthTokenCache $credentials,
4949
?callable $tokenCallback = null
50+
) {
51+
return $this->attachToHttp($http, $credentials, $tokenCallback);
52+
}
53+
54+
private function attachToHttp(
55+
ClientInterface $http,
56+
FetchAuthTokenInterface $credentials,
57+
?callable $tokenCallback = null
5058
) {
5159
// if we end up needing to make an HTTP request to retrieve credentials, we
5260
// can use our existing one, but we need to throw exceptions so the error
@@ -63,9 +71,7 @@ public function attachCredentialsCache(
6371
$config['handler']->remove('google_auth');
6472
$config['handler']->push($middleware, 'google_auth');
6573
$config['auth'] = 'google_auth';
66-
$http = new Client($config);
67-
68-
return $http;
74+
return new Client($config);
6975
}
7076

7177
public function attachToken(ClientInterface $http, array $token, array $scopes)

src/Client.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use Google\Auth\Credentials\UserRefreshCredentials;
2828
use Google\Auth\CredentialsLoader;
2929
use Google\Auth\FetchAuthTokenCache;
30+
use Google\Auth\FetchAuthTokenInterface;
3031
use Google\Auth\GetUniverseDomainInterface;
3132
use Google\Auth\HttpHandler\HttpHandlerFactory;
3233
use Google\Auth\OAuth2;
@@ -94,7 +95,7 @@ class Client
9495
private $logger;
9596

9697
/**
97-
* @var ?CredentialsLoader $credentials
98+
* @var ?FetchAuthTokenInterface $credentials
9899
*/
99100
private $credentials;
100101

@@ -122,10 +123,10 @@ class Client
122123
* Your Google Cloud client ID found in https://developers.google.com/console
123124
* @type string $client_secret
124125
* Your Google Cloud client secret found in https://developers.google.com/console
125-
* @type string|array|CredentialsLoader $credentials
126+
* @type string|array|FetchAuthTokenInterface $credentials
126127
* Can be a path to JSON credentials or an array representing those
127128
* credentials (@see Google\Client::setAuthConfig), or an instance of
128-
* {@see CredentialsLoader}.
129+
* {@see FetchAuthTokenInterface}.
129130
* @type string|array $scopes
130131
* {@see Google\Client::setScopes}
131132
* @type string $quota_project
@@ -217,7 +218,7 @@ public function __construct(array $config = [])
217218
], $config);
218219

219220
if (!is_null($this->config['credentials'])) {
220-
if ($this->config['credentials'] instanceof CredentialsLoader) {
221+
if ($this->config['credentials'] instanceof FetchAuthTokenInterface) {
221222
$this->credentials = $this->config['credentials'];
222223
} else {
223224
$this->setAuthConfig($this->config['credentials']);
@@ -464,7 +465,8 @@ public function authorize(?ClientInterface $http = null)
464465
$authHandler = $this->getAuthHandler();
465466

466467
// These conditionals represent the decision tree for authentication
467-
// 1. Check if a Google\Auth\CredentialsLoader instance has been supplied via the "credentials" option
468+
// 1. Check if an instance of Google\Auth\FetchAuthTokenInterface has
469+
// been supplied via the "credentials" option
468470
// 2. Check for Application Default Credentials
469471
// 3a. Check for an Access Token
470472
// 3b. If access token exists but is expired, try to refresh it

0 commit comments

Comments
 (0)