Google Auth Library Client - Class SimpleMiddleware (1.45.2)

Reference documentation and code samples for the Google Auth Library Client class SimpleMiddleware.

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

Requests are accessed using the Simple API access developer key.

Namespace

Google \ Auth \ Middleware

Methods

__construct

Create a new Simple plugin.

The configuration array expects one option

  • key: required, otherwise InvalidArgumentException is thrown
Parameter
Name Description
config array

Configuration array

__invoke

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');

Parameter
Name Description
handler callable
Returns
Type Description
Closure