PHPackages                             happyr/google-site-authenticator-bundle - 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. happyr/google-site-authenticator-bundle

ActiveSymfony-bundle[Authentication &amp; Authorization](/categories/authentication)

happyr/google-site-authenticator-bundle
=======================================

Authenticate your website (not your users) with Google API. Can be used instead as Domain-Wide Delegation of Authority

1.2.0(5y ago)1315.2k5[2 issues](https://github.com/Happyr/GoogleSiteAuthenticatorBundle/issues)MITPHPPHP ^7.1CI failing

Since Nov 23Pushed 5y ago3 watchersCompare

[ Source](https://github.com/Happyr/GoogleSiteAuthenticatorBundle)[ Packagist](https://packagist.org/packages/happyr/google-site-authenticator-bundle)[ Docs](http://developer.happyr.com)[ RSS](/packages/happyr-google-site-authenticator-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (14)Versions (16)Used By (0)

Happyr Google Site Authenticator Bundle
=======================================

[](#happyr-google-site-authenticator-bundle)

[![Latest Version](https://camo.githubusercontent.com/dddb7cd2fd2d4580c4fa596aa2fa77675386e1f57a9a7e0bc9632062f0d871c7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f4861707079722f476f6f676c655369746541757468656e74696361746f7242756e646c652e7376673f7374796c653d666c61742d737175617265)](https://github.com/Happyr/GoogleSiteAuthenticatorBundle/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Build Status](https://camo.githubusercontent.com/83ff16e24a0673a7ec6245448abebf78134bed6fc0e5a6fc587f02301eeecdc4/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f4861707079722f476f6f676c655369746541757468656e74696361746f7242756e646c652e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/Happyr/GoogleSiteAuthenticatorBundle)[![Code Coverage](https://camo.githubusercontent.com/714e73b403b81a5bf57b9aafb6da7f523be45ae3360b27dd05404416b6eabd51/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f4861707079722f476f6f676c655369746541757468656e74696361746f7242756e646c652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/Happyr/GoogleSiteAuthenticatorBundle)[![Quality Score](https://camo.githubusercontent.com/ea7826fb1cc8a99ff97d6bd3fa027266f4b49a08db78227498b24a4ffcdce3ed/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f4861707079722f476f6f676c655369746541757468656e74696361746f7242756e646c652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/Happyr/GoogleSiteAuthenticatorBundle)[![Total Downloads](https://camo.githubusercontent.com/8a36941946a4f14ab146f4ea46b412d9f05898fc41b2d22e98e1644cb04a1206/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6861707079722f676f6f676c652d736974652d61757468656e74696361746f722d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/happyr/google-site-authenticator-bundle)

In some situations you want a website to make API request on the behalf of you (not your users). Example when you want to fetch website data from Google Analytics or upload database dumps to Google Drive. The solution Google offers for this is a [Domain-Wide Delegation of Authority](https://developers.google.com/drive/web/delegation). But that solution requires you be a paying customer on Google Apps. I wanted a free solution so I created this bundle.

This bundle is using a normal OAuth for a web application, but it authenticates your google account (or accounts) but **not** your users'. It saves the access token in a cache until you manually revoke it.

***Read all of this README file to understand how to get started and authenticated***

Install
-------

[](#install)

Use composer to get the bundle. You do also have to get a PSR-6 cache implementation.

```
$ php composer.phar require happyr/google-site-authenticator-bundle cache/redis-adapter
```

Activate this bundle in AppKernel.

```
new Happyr\GoogleSiteAuthenticatorBundle\HappyrGoogleSiteAuthenticatorBundle(),
```

Include the routing.yml and make sure it is protected from normal users.

```
// app/config/routing.yml
happyr_google_site_authenticator:
    resource: "@HappyrGoogleSiteAuthenticatorBundle/Resources/config/routing.yml"
    prefix:   /admin
```

### Get API credentials

[](#get-api-credentials)

You will find all information on the [Google Console](https://code.google.com/apis/console). Go in to the console and click on "APIs" in the sidebar to select those API you want to use.

To retrieve the API-key and secret, click on "Credentials" in the sidebar and then "Create new ClientID". And create a client ID for a **web application**. Make sure to specify the correct *Authorized redirect URIs*. If you used the configuration above you should use the following url:

```
http://www.domain.com/admin/authenticate-google/return-url

```

When you are done you will get a *client id* and a *client secret*. Save those for the next section.

### Configure

[](#configure)

This bundle will fetch an access token and save it to cache. The [PHPCacheAdapterBundle](https://github.com/php-cache/adapter-bundle)is an excellent bundle for this. You may use one of many predefined cache providers like; file\_system, apc, mongodb etc. Read more about caching here:

It also allows you to create your own cache provider. Here is an example configuration:

```
cache_adapter:
  providers:
    my_redis:
      factory: 'cache.factory.redis'
```

To configure the Happyr Google Site Authenticator bundle you need to add your API credentials and select a service extending `Psr\Cache\CacheItemInterface`. If you are using the configuration above you could use the following values:

```
happyr_google_site_authenticator:
  cache_service: 'cache.provider.my_redis'
  tokens:
    google_drive:
      client_id: '00000000000-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com'
      client_secret: 'xxxxx-xxxxx_xxxxxxxxxxxx'
      redirect_url: 'http://www.domain.com/admin/authenticate-google/return-url'
      scopes: ['https://www.googleapis.com/auth/drive']
```

You will find all available scopes [here](https://developers.google.com/oauthplayground/).

The config above will configure a token called *google\_drive*. You may, of course, configure more tokens. To get a Google\_Client instance with those credentials:

```
$clientProvider = $this->get('happyr.google.client_provider');
$client = $clientProvider->getClient('google_drive');

// or don't use the client provider
$client = $this->get('google.client.google_drive');

// if you only have one token configured
$client = $this->get('google.client');
```

Authenticating
--------------

[](#authenticating)

To make sure you fetch an access token you need to navigate to `http://www.domain.com/admin/authenticate-google` and click on *Authenticate*. You will be asked to sign in with your Google account and grant the permissions. The access token retrieved will be saved by the cache service. You want to make sure this is stored for a very long time.

When you are authenticated you may use `happyr.google.client_provider` to get an authenticated client.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 96.6% 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 ~155 days

Total

15

Last Release

2014d ago

Major Versions

0.3.2 → 1.0.02019-02-11

PHP version history (3 changes)0.1.0PHP &gt;=5.4

0.3PHP ^5.5 || ^7.0

1.0.0PHP ^7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/401ccc5eea13c60cf807ae982af00e368e2166e2f26d8eb541dcd881a57385bc?d=identicon)[Nyholm](/maintainers/Nyholm)

---

Top Contributors

[![Nyholm](https://avatars.githubusercontent.com/u/1275206?v=4)](https://github.com/Nyholm "Nyholm (57 commits)")[![maguramarkian](https://avatars.githubusercontent.com/u/2134057?v=4)](https://github.com/maguramarkian "maguramarkian (1 commits)")[![segli](https://avatars.githubusercontent.com/u/3708981?v=4)](https://github.com/segli "segli (1 commits)")

---

Tags

apigoogleAuthenticationsite wideDomain-Wide DelegationDomain-Wide

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/happyr-google-site-authenticator-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/happyr-google-site-authenticator-bundle/health.svg)](https://phpackages.com/packages/happyr-google-site-authenticator-bundle)
```

###  Alternatives

[sylius/sylius

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

8.4k5.6M651](/packages/sylius-sylius)[nelmio/api-doc-bundle

Generates documentation for your REST API from attributes

2.3k63.6M233](/packages/nelmio-api-doc-bundle)[symfony/security-bundle

Provides a tight integration of the Security component into the Symfony full-stack framework

2.5k172.9M1.8k](/packages/symfony-security-bundle)[scheb/2fa

Two-factor authentication for Symfony applications (please use scheb/2fa-bundle to install)

578630.7k1](/packages/scheb-2fa)[scheb/2fa-bundle

A generic interface to implement two-factor authentication in Symfony applications

6914.0M62](/packages/scheb-2fa-bundle)[simplesamlphp/simplesamlphp

A PHP implementation of a SAML 2.0 service provider and identity provider.

1.1k12.4M193](/packages/simplesamlphp-simplesamlphp)

PHPackages © 2026

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