PHPackages                             cedcommerce/google-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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. cedcommerce/google-auth

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

cedcommerce/google-auth
=======================

Google Auth Library for PHP

1.0.0(7y ago)03511Apache-2.0PHPPHP &gt;=5.4

Since Mar 18Pushed 7y ago2 watchersCompare

[ Source](https://github.com/cedcommerce/google-auth)[ Packagist](https://packagist.org/packages/cedcommerce/google-auth)[ Docs](http://github.com/google/google-auth-library-php)[ RSS](/packages/cedcommerce-google-auth/feed)WikiDiscussions master Synced 5d ago

READMEChangelog (1)Dependencies (9)Versions (2)Used By (1)

Google Auth Library for PHP
===========================

[](#google-auth-library-for-php)

 Homepage Authors [Tim Emiola](mailto:temiola@google.com) [Stanley Cheung](mailto:stanleycheung@google.com) [Brent Shaffer](mailto:betterbrent@google.com) CopyrightCopyright © 2015 Google, Inc. LicenseApache 2.0Description
-----------

[](#description)

This is Google's officially supported PHP client library for using OAuth 2.0 authorization and authentication with Google APIs.

### Installing via Composer

[](#installing-via-composer)

The recommended way to install the google auth library is through [Composer](http://getcomposer.org).

```
# Install Composer
curl -sS https://getcomposer.org/installer | php
```

Next, run the Composer command to install the latest stable version:

```
composer.phar require google/auth
```

Application Default Credentials
-------------------------------

[](#application-default-credentials)

This library provides an implementation of [application default credentials](https://developers.google.com/accounts/docs/application-default-credentials) for PHP.

The Application Default Credentials provide a simple way to get authorization credentials for use in calling Google APIs.

They are best suited for cases when the call needs to have the same identity and authorization level for the application independent of the user. This is the recommended approach to authorize calls to Cloud APIs, particularly when you're building an application that uses Google Compute Engine.

#### Download your Service Account Credentials JSON file

[](#download-your-service-account-credentials-json-file)

To use `Application Default Credentials`, You first need to download a set of JSON credentials for your project. Go to **APIs &amp; Auth** &gt; **Credentials** in the [Google Developers Console](https://console.developers.google.com) and select **Service account** from the **Add credentials** dropdown.

> This file is your *only copy* of these credentials. It should never be committed with your source code, and should be stored securely.

Once downloaded, store the path to this file in the `GOOGLE_APPLICATION_CREDENTIALS` environment variable.

```
putenv('GOOGLE_APPLICATION_CREDENTIALS=/path/to/my/credentials.json');
```

> PHP's `putenv` function is just one way to set an environment variable. Consider using `.htaccess` or apache configuration files as well.

#### Enable the API you want to use

[](#enable-the-api-you-want-to-use)

Before making your API call, you must be sure the API you're calling has been enabled. Go to **APIs &amp; Auth** &gt; **APIs** in the [Google Developers Console](https://console.developers.google.com) and enable the APIs you'd like to call. For the example below, you must enable the `Drive API`.

#### Call the APIs

[](#call-the-apis)

As long as you update the environment variable below to point to *your* JSON credentials file, the following code should output a list of your Drive files.

```
use Google\Auth\ApplicationDefaultCredentials;
use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;

// specify the path to your application credentials
putenv('GOOGLE_APPLICATION_CREDENTIALS=/path/to/my/credentials.json');

// define the scopes for your API call
$scopes = ['https://www.googleapis.com/auth/drive.readonly'];

// create middleware
$middleware = ApplicationDefaultCredentials::getMiddleware($scopes);
$stack = HandlerStack::create();
$stack->push($middleware);

// create the HTTP client
$client = new Client([
  'handler' => $stack,
  'base_uri' => 'https://www.googleapis.com',
  'auth' => 'google_auth'  // authorize all requests
]);

// make the request
$response = $client->get('drive/v2/files');

// show the result!
print_r((string) $response->getBody());
```

##### Guzzle 5 Compatibility

[](#guzzle-5-compatibility)

If you are using [Guzzle 5](http://docs.guzzlephp.org/en/5.3), replace the `create middleware` and `create the HTTP Client` steps with the following:

```
// create the HTTP client
$client = new Client([
  'base_url' => 'https://www.googleapis.com',
  'auth' => 'google_auth'  // authorize all requests
]);

// create subscriber
$subscriber = ApplicationDefaultCredentials::getSubscriber($scopes);
$client->getEmitter()->attach($subscriber);
```

License
-------

[](#license)

This library is licensed under Apache 2.0. Full license text is available in [COPYING](https://github.com/google/google-auth-library-php/tree/master/COPYING).

Contributing
------------

[](#contributing)

See [CONTRIBUTING](https://github.com/google/google-auth-library-php/tree/master/CONTRIBUTING.md).

Support
-------

[](#support)

Please [report bugs at the project on Github](https://github.com/google/google-auth-library-php/issues). Don't hesitate to [ask questions](http://stackoverflow.com/questions/tagged/google-auth-library-php)about the client or APIs on [StackOverflow](http://stackoverflow.com).

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity55

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

Unknown

Total

1

Last Release

2614d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/dedeabfc3e40c06069c4ee968b589468b978e792edcedf75626b7ba28377f169?d=identicon)[milindsingh](/maintainers/milindsingh)

![](https://www.gravatar.com/avatar/dca8bcc20dc1c873ea58cecfb2b669b93c188c5e6da8581e5534dfbfaab467b2?d=identicon)[cedcommerce](/maintainers/cedcommerce)

---

Top Contributors

[![milindsingh](https://avatars.githubusercontent.com/u/13949703?v=4)](https://github.com/milindsingh "milindsingh (2 commits)")

---

Tags

googleAuthenticationoauth2

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/cedcommerce-google-auth/health.svg)

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

###  Alternatives

[google/auth

Google Auth Library for PHP

1.4k272.7M162](/packages/google-auth)[kreait/firebase-php

Firebase Admin SDK

2.4k39.7M72](/packages/kreait-firebase-php)[kinde-oss/kinde-auth-php

Kinde PHP SDK for authentication

2369.5k3](/packages/kinde-oss-kinde-auth-php)

PHPackages © 2026

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