PHPackages                             phpexperts/gcloud-auth - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. phpexperts/gcloud-auth

ActiveLibrary[API Development](/categories/api)

phpexperts/gcloud-auth
======================

A drop-dead simple way to authenticate APIs with Google Cloud without needing the gcloud-api dependency.

v1.3.0(6mo ago)110MITPHPPHP &gt;=8.0

Since Apr 10Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/PHPExpertsInc/gcloud-auth)[ Packagist](https://packagist.org/packages/phpexperts/gcloud-auth)[ Docs](https://github.com/PHPExpertsInc/gcloud-auth)[ RSS](/packages/phpexperts-gcloud-auth/feed)WikiDiscussions trunk Synced 1mo ago

READMEChangelogDependencies (8)Versions (5)Used By (0)

Google Cloud Auth
=================

[](#google-cloud-auth)

![TravisCI]()![Maintainability]()![Test Coverage]()

GCloud Auth is a PHP Experts, Inc., Project for authenticating with Google Cloud API without needing the huge gcloud binary.

As of April 2025, the `google-cloud-cli` weighs in at around 150 MB, not counting dependencies, and over 550 MB counting dependencies, on modern Linux systems.

Using the `google/apiclient` composer package itself weighs in at 141 MB.

This project, by comparison, weighs in around 10 KB (or 15,000x smaller).

It provides everything you need to retrieve an OAuth2 token for authenticating with Google Cloud API services. It autogenerates the JWT token necessary for this, using ext-openssl.

It includes a drop-in `phpexperts/rest-speaker` `GoogleAuth` driver, but it can also be used standalone by any PHP project.

Installation
------------

[](#installation)

Via Composer

```
composer require phpexperts/gcloud-auth
```

Usage
-----

[](#usage)

For use with `phpexperts/rest-speaker`:

```
use PHPExperts\GoogleCloudAuth\GoogleCloudAuth;
use PHPExperts\RESTSpeaker\RESTSpeaker;

$api = new RESTSpeaker(new GoogleCloudAuth('relative/path/to/services.json'));
```

For use with any other PHP project:

```
use PHPExperts\GoogleCloudAuth\GoogleCloudAuth;
$gcloudAuth = new GoogleCloudAuth('relative/path/to/services.json');

// Returns the raw Oauth2Token as a string.
$gcloudOauth2Token = $gcloudAuth->obtainGCloudOauthToken();

$url = "https://storage.googleapis.com/storage/v1/b?project=$projectId";
$http = new \GuzzleHttp\Client([
    'headers' => [
        'Content-Type'  => 'application/json',
        'Authorization' => "Bearer $gcloudOauth2Token",
    ]
]);
$response = $http->get($url);
```

Use cases
---------

[](#use-cases)

✔ Can authenticate with GCloud ✔ Handles invalid service account path ✔ Handles invalid service account data ✔ Handles error responses from Google Cloud ✔ Can override time for testing ✔ Will cache the OAuth2 Token until expiration ✔ Can synthesize speech using the GCloud API

Testing
-------

[](#testing)

```
phpunit --testdox
```

Contributors
------------

[](#contributors)

[Theodore R. Smith](https://www.phpexperts.pro/%5D)
GPG Fingerprint: 4BF8 2613 1C34 87AC D28F 2AD8 EB24 A91D D612 5690
CEO: PHP Experts, Inc.

License
-------

[](#license)

MIT license. Please see the [license file](LICENSE) for more information.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance65

Regular maintenance activity

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~64 days

Total

4

Last Release

209d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3f3a2dd16766f6b03c330e65aaca9dfb97f1bbbb41c5e2af5681f58f670b7917?d=identicon)[hopeseekr](/maintainers/hopeseekr)

---

Top Contributors

[![hopeseekr](https://avatars.githubusercontent.com/u/1125541?v=4)](https://github.com/hopeseekr "hopeseekr (5 commits)")

---

Tags

apigoogle cloudgcloud

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/phpexperts-gcloud-auth/health.svg)

```
[![Health](https://phpackages.com/badges/phpexperts-gcloud-auth/health.svg)](https://phpackages.com/packages/phpexperts-gcloud-auth)
```

###  Alternatives

[m165437/laravel-blueprint-docs

API Blueprint Renderer for Laravel

22779.0k](/packages/m165437-laravel-blueprint-docs)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
