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

Requests are accessed using the Simple API access developer key.

CloneableInstantiable
Methods
public __construct(array $config)
 

Create a new Simple plugin.

The configuration array expects one option

  • key: required, otherwise InvalidArgumentException is thrown
    public __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');

    • return Closure
    Properties
    private $config
     
    • var array
    © 2020 Bruce Wells
    Search Namespaces \ Classes
    ConfigurationNumbers (0-9.) only