Google Auth Library Client - Class ProxyAuthTokenMiddleware (1.45.2)

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

ProxyAuthTokenMiddleware is a Guzzle Middleware that adds an Authorization header provided by an object implementing FetchAuthTokenInterface.

The FetchAuthTokenInterface#fetchAuthToken is used to obtain a hash; one of the values value in that hash is added as the authorization header.

Requests will be accessed with the authorization header:

'proxy-authorization' 'Bearer

Namespace

Google \ Auth \ Middleware

Methods

__construct

Creates a new ProxyAuthTokenMiddleware.

Parameters
Name Description
fetcher Google\Auth\FetchAuthTokenInterface

is used to fetch the auth token

httpHandler callable|null

(optional) callback which delivers psr7 request

tokenCallback callable|null

(optional) function to be called when a new token is fetched.

__invoke

Updates the request with an Authorization header when auth is 'google_auth'.

use Google\Auth\Middleware\ProxyAuthTokenMiddleware; use Google\Auth\OAuth2; use GuzzleHttp\Client; use GuzzleHttp\HandlerStack;

$config = [..

$client = new Client([ 'handler' => $stack, 'base_uri' => 'https://www.googleapis.com/taskqueue/v1beta2/projects/', 'proxy_auth' => 'google_auth' // authorize all requests ]);

$res = $client->get('myproject/taskqueues/myqueue');

Parameter
Name Description
handler callable
Returns
Type Description
Closure