class SimpleMiddleware (View source)

SimpleMiddleware is a Guzzle Middleware that implements Google's Simple API access.

Requests are accessed using the Simple API access developer key.

Methods

__construct(array $config)

Create a new Simple plugin.

__invoke(callable $handler)

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

Details

__construct(array $config)

Create a new Simple plugin.

The configuration array expects one option

  • key: required, otherwise InvalidArgumentException is thrown

Parameters

array $config

Configuration array

Closure __invoke(callable $handler)

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

use Google\Auth\Middleware\SimpleMiddleware; use GuzzleHttp\Client; use GuzzleHttp\HandlerStack;

$my_key = 'is not the same as yours'; $middleware = new SimpleMiddleware(['key' => $my_key]); $stack = HandlerStack::create(); $stack->push($middleware);

$client = new Client([ 'handler' => $stack, 'base_uri' => 'https://www.googleapis.com/discovery/v1/', 'auth' => 'simple' ]);

$res = $client->get('drive/v2/rest');

Parameters

callable $handler

Return Value

Closure