Documentation

SimpleSubscriber
in package
implements SubscriberInterface

SimpleSubscriber is a Guzzle Subscriber that implements Google's Simple API access.

Requests are accessed using the Simple API access developer key.

Table of Contents

Interfaces

SubscriberInterface

Properties

$config  : array<string|int, mixed>

Methods

__construct()  : mixed
Create a new Simple plugin.
getEvents()  : array<string|int, mixed>
onBefore()  : mixed
Updates the request query with the developer key if auth is set to simple.

Properties

Methods

__construct()

Create a new Simple plugin.

public __construct(array<string|int, mixed> $config) : mixed

The configuration array expects one option

  • key: required, otherwise InvalidArgumentException is thrown
Parameters
$config : array<string|int, mixed>

Configuration array

getEvents()

public getEvents() : array<string|int, mixed>
Return values
array<string|int, mixed>

onBefore()

Updates the request query with the developer key if auth is set to simple.

public onBefore(BeforeEvent $event) : mixed

Example:

use Google\Auth\Subscriber\SimpleSubscriber;
use GuzzleHttp\Client;

$my_key = 'is not the same as yours';
$subscriber = new SimpleSubscriber(['key' => $my_key]);

$client = new Client([
    'base_url' => 'https://www.googleapis.com/discovery/v1/',
    'defaults' => ['auth' => 'simple']
]);
$client->getEmitter()->attach($subscriber);

$res = $client->get('drive/v2/rest');
Parameters
$event : BeforeEvent

        
On this page

Search results