2017 © Pedro Peláez
 

symfony-bundle google-site-authenticator-bundle

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

image

happyr/google-site-authenticator-bundle

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

  • Thursday, January 11, 2018
  • by Nyholm
  • Repository
  • 4 Watchers
  • 9 Stars
  • 8,468 Installations
  • PHP
  • 0 Dependents
  • 2 Suggesters
  • 5 Forks
  • 1 Open issues
  • 10 Versions
  • 4 % Grown

The README.md

Happyr Google Site Authenticator Bundle

Latest Version Software License Build Status Code Coverage Quality Score Total Downloads, (*1)

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. But that solution requires you be a paying customer on Google Apps. I wanted a free solution so I created this bundle., (*2)

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., (*3)

Read all of this README file to understand how to get started and authenticated, (*4)

Install

Use composer to get the bundle. You do also have to get a PSR-6 cache implementation., (*5)

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

Activate this bundle in AppKernel., (*6)

new Happyr\GoogleSiteAuthenticatorBundle\HappyrGoogleSiteAuthenticatorBundle(),

Include the routing.yml and make sure it is protected from normal users., (*7)

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

Get API credentials

You will find all information on the Google Console. Go in to the console and click on "APIs" in the sidebar to select those API you want to use., (*8)

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:, (*9)

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., (*10)

Configure

This bundle will fetch an access token and save it to cache. The PHPCacheAdapterBundle 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: http://www.php-cache.com/, (*11)

It also allows you to create your own cache provider. Here is an example configuration:, (*12)

``` yml cache_adapter: providers: my_redis: factory: 'cache.factory.redis', (*13)


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: ``` yml 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., (*14)

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:, (*15)

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

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

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

```, (*19)

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., (*20)

When you are authenticated you may use happyr.google.client_provider to get an authenticated client., (*21)

The Versions

11/01 2018

dev-master

9999999-dev http://developer.happyr.com

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

  Sources   Download

MIT

The Requires

 

The Development Requires

api authentication google domain-wide delegation site-wide domain-wide

10/08 2016

0.3.2

0.3.2.0 http://developer.happyr.com

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

  Sources   Download

MIT

The Requires

 

The Development Requires

api authentication google domain-wide delegation site-wide domain-wide

01/08 2016

0.3.1

0.3.1.0 http://developer.happyr.com

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

  Sources   Download

MIT

The Requires

 

The Development Requires

api authentication google domain-wide delegation site-wide domain-wide

01/08 2016

0.3

0.3.0.0 http://developer.happyr.com

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

  Sources   Download

MIT

The Requires

 

The Development Requires

api authentication google domain-wide delegation site-wide domain-wide

29/10 2015

0.2.2

0.2.2.0 http://developer.happyr.com

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

  Sources   Download

MIT

The Requires

 

api authentication google domain-wide delegation site-wide domain-wide

14/10 2015

0.2.1

0.2.1.0 http://developer.happyr.com

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

  Sources   Download

MIT

The Requires

 

api authentication google domain-wide delegation site-wide domain-wide

03/06 2015

0.2.0

0.2.0.0 http://developer.happyr.com

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

  Sources   Download

MIT

The Requires

 

api authentication google domain-wide delegation site-wide domain-wide

23/11 2014

0.1.2

0.1.2.0 http://developer.happyr.com

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

  Sources   Download

MIT

The Requires

 

api authentication google domain-wide delegation site-wide domain-wide

23/11 2014

0.1.1

0.1.1.0 http://developer.happyr.com

Authenticate your site with Google API. Can be used instead as Domain-Wide Delegation of Authority

  Sources   Download

MIT

The Requires

 

api authentication google domain-wide delegation site-wide domain-wide

23/11 2014

0.1.0

0.1.0.0 http://developer.happyr.com

Authenticate your site with Google API. Can be used instead as Domain-Wide Delegation of Authority

  Sources   Download

MIT

The Requires

 

api authentication google domain-wide delegation site-wide domain-wide