PHPackages                             jaeger/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. jaeger/google-auth

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

jaeger/google-auth
==================

Google Auth Library for PHP

v0.11(9y ago)0691Apache-2.0PHPPHP &gt;=5.4

Since Sep 16Pushed 9y ago1 watchersCompare

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

READMEChangelog (1)Dependencies (7)Versions (12)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_url' => '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 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~35 days

Recently: every ~46 days

Total

11

Last Release

3579d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/167618?v=4)[Jae](/maintainers/jae)[@Jae](https://github.com/Jae)

---

Top Contributors

[![bshaffer](https://avatars.githubusercontent.com/u/103941?v=4)](https://github.com/bshaffer "bshaffer (49 commits)")[![tbetbetbe](https://avatars.githubusercontent.com/u/9272342?v=4)](https://github.com/tbetbetbe "tbetbetbe (45 commits)")[![stanley-cheung](https://avatars.githubusercontent.com/u/11674202?v=4)](https://github.com/stanley-cheung "stanley-cheung (38 commits)")[![murgatroid99](https://avatars.githubusercontent.com/u/961599?v=4)](https://github.com/murgatroid99 "murgatroid99 (15 commits)")[![cedricziel](https://avatars.githubusercontent.com/u/418970?v=4)](https://github.com/cedricziel "cedricziel (4 commits)")[![silvolu](https://avatars.githubusercontent.com/u/596919?v=4)](https://github.com/silvolu "silvolu (3 commits)")[![dwsupplee](https://avatars.githubusercontent.com/u/2079879?v=4)](https://github.com/dwsupplee "dwsupplee (2 commits)")[![mortonfox](https://avatars.githubusercontent.com/u/495892?v=4)](https://github.com/mortonfox "mortonfox (1 commits)")[![jae-jae](https://avatars.githubusercontent.com/u/5620429?v=4)](https://github.com/jae-jae "jae-jae (1 commits)")[![michaelbausor](https://avatars.githubusercontent.com/u/14846209?v=4)](https://github.com/michaelbausor "michaelbausor (1 commits)")[![aiwha-dev](https://avatars.githubusercontent.com/u/9433667?v=4)](https://github.com/aiwha-dev "aiwha-dev (1 commits)")[![Nyholm](https://avatars.githubusercontent.com/u/1275206?v=4)](https://github.com/Nyholm "Nyholm (1 commits)")

---

Tags

googleAuthenticationoauth2

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[google/auth

Google Auth Library for PHP

1.4k286.7M205](/packages/google-auth)[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.2k532.1M2.5k](/packages/aws-aws-sdk-php)[tempest/framework

The PHP framework that gets out of your way.

2.2k31.1k12](/packages/tempest-framework)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.8M712](/packages/sylius-sylius)[kreait/firebase-php

Firebase Admin SDK

2.4k42.7M84](/packages/kreait-firebase-php)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k496.1k33](/packages/neuron-core-neuron-ai)

PHPackages © 2026

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