updated plugin WP Mail SMTP
version 2.1.1
This commit is contained in:
@ -23,7 +23,7 @@ function oauth2client_php_autoload($className)
|
||||
}
|
||||
if (count($classPath) > 3) {
|
||||
// Maximum class file path depth in this project is 3.
|
||||
$classPath = array_slice($classPath, 0, 3);
|
||||
$classPath = array_slice($classPath, 0, 3);
|
||||
}
|
||||
$filePath = dirname(__FILE__) . '/src/' . implode('/', $classPath) . '.php';
|
||||
if (file_exists($filePath)) {
|
||||
|
@ -82,22 +82,19 @@ class AccessToken
|
||||
* accepted. By default, the id token must have been issued to this OAuth2 client.
|
||||
*
|
||||
* @param string $token The JSON Web Token to be verified.
|
||||
* @param array $options [optional] {
|
||||
* Configuration options.
|
||||
*
|
||||
* @type string $audience The indended recipient of the token.
|
||||
* @type string $issuer The intended issuer of the token.
|
||||
* @type string $certsLocation The location (remote or local) from which
|
||||
* @param array $options [optional] Configuration options.
|
||||
* @param string $options.audience The indended recipient of the token.
|
||||
* @param string $options.issuer The intended issuer of the token.
|
||||
* @param string $options.cacheKey The cache key of the cached certs. Defaults to
|
||||
* the sha1 of $certsLocation if provided, otherwise is set to
|
||||
* "federated_signon_certs_v3".
|
||||
* @param string $options.certsLocation The location (remote or local) from which
|
||||
* to retrieve certificates, if not cached. This value should only be
|
||||
* provided in limited circumstances in which you are sure of the
|
||||
* behavior.
|
||||
* @type string $cacheKey The cache key of the cached certs. Defaults to
|
||||
* the sha1 of $certsLocation if provided, otherwise is set to
|
||||
* "federated_signon_certs_v3".
|
||||
* @type bool $throwException Whether the function should throw an
|
||||
* @param bool $options.throwException Whether the function should throw an
|
||||
* exception if the verification fails. This is useful for
|
||||
* determining the reason verification failed.
|
||||
* }
|
||||
* @return array|bool the token payload, if successful, or false if not.
|
||||
* @throws InvalidArgumentException If certs could not be retrieved from a local file.
|
||||
* @throws InvalidArgumentException If received certs are in an invalid format.
|
||||
@ -129,7 +126,8 @@ class AccessToken
|
||||
$alg = $this->determineAlg($certs);
|
||||
if (!in_array($alg, ['RS256', 'ES256'])) {
|
||||
throw new InvalidArgumentException(
|
||||
'unrecognized "alg" in certs, expected ES256 or RS256');
|
||||
'unrecognized "alg" in certs, expected ES256 or RS256'
|
||||
);
|
||||
}
|
||||
try {
|
||||
if ($alg == 'RS256') {
|
||||
@ -186,13 +184,11 @@ class AccessToken
|
||||
*
|
||||
* @param string $token The JSON Web Token to be verified.
|
||||
* @param array $certs Certificate array according to the JWK spec (see
|
||||
* https://tools.ietf.org/html/rfc7517).
|
||||
* https://tools.ietf.org/html/rfc7517).
|
||||
* @param string|null $audience If set, returns false if the provided
|
||||
* audience does not match the "aud" claim on
|
||||
* the JWT.
|
||||
* audience does not match the "aud" claim on the JWT.
|
||||
* @param string|null $issuer If set, returns false if the provided
|
||||
* issuer does not match the "iss" claim on
|
||||
* the JWT.
|
||||
* issuer does not match the "iss" claim on the JWT.
|
||||
* @return array|bool the token payload, if successful, or false if not.
|
||||
*/
|
||||
private function verifyEs256($token, array $certs, $audience = null, $issuer = null)
|
||||
@ -228,13 +224,11 @@ class AccessToken
|
||||
*
|
||||
* @param string $token The JSON Web Token to be verified.
|
||||
* @param array $certs Certificate array according to the JWK spec (see
|
||||
* https://tools.ietf.org/html/rfc7517).
|
||||
* https://tools.ietf.org/html/rfc7517).
|
||||
* @param string|null $audience If set, returns false if the provided
|
||||
* audience does not match the "aud" claim on
|
||||
* the JWT.
|
||||
* audience does not match the "aud" claim on the JWT.
|
||||
* @param string|null $issuer If set, returns false if the provided
|
||||
* issuer does not match the "iss" claim on
|
||||
* the JWT.
|
||||
* issuer does not match the "iss" claim on the JWT.
|
||||
* @return array|bool the token payload, if successful, or false if not.
|
||||
*/
|
||||
private function verifyRs256($token, array $certs, $audience = null, $issuer = null)
|
||||
@ -325,6 +319,7 @@ class AccessToken
|
||||
* are PEM encoded certificates.
|
||||
*
|
||||
* @param string $location The location from which to retrieve certs.
|
||||
* @param string $cacheKey The key under which to cache the retrieved certs.
|
||||
* @param array $options [optional] Configuration options.
|
||||
* @return array
|
||||
* @throws InvalidArgumentException If received certs are in an invalid format.
|
||||
|
@ -46,23 +46,25 @@ use Psr\Cache\CacheItemPoolInterface;
|
||||
*
|
||||
* This allows it to be used as follows with GuzzleHttp\Client:
|
||||
*
|
||||
* use Google\Auth\ApplicationDefaultCredentials;
|
||||
* use GuzzleHttp\Client;
|
||||
* use GuzzleHttp\HandlerStack;
|
||||
* ```
|
||||
* use Google\Auth\ApplicationDefaultCredentials;
|
||||
* use GuzzleHttp\Client;
|
||||
* use GuzzleHttp\HandlerStack;
|
||||
*
|
||||
* $middleware = ApplicationDefaultCredentials::getMiddleware(
|
||||
* 'https://www.googleapis.com/auth/taskqueue'
|
||||
* );
|
||||
* $stack = HandlerStack::create();
|
||||
* $stack->push($middleware);
|
||||
* $middleware = ApplicationDefaultCredentials::getMiddleware(
|
||||
* 'https://www.googleapis.com/auth/taskqueue'
|
||||
* );
|
||||
* $stack = HandlerStack::create();
|
||||
* $stack->push($middleware);
|
||||
*
|
||||
* $client = new Client([
|
||||
* 'handler' => $stack,
|
||||
* 'base_uri' => 'https://www.googleapis.com/taskqueue/v1beta2/projects/',
|
||||
* 'auth' => 'google_auth' // authorize all requests
|
||||
* ]);
|
||||
* $client = new Client([
|
||||
* 'handler' => $stack,
|
||||
* 'base_uri' => 'https://www.googleapis.com/taskqueue/v1beta2/projects/',
|
||||
* 'auth' => 'google_auth' // authorize all requests
|
||||
* ]);
|
||||
*
|
||||
* $res = $client->get('myproject/taskqueues/myqueue');
|
||||
* $res = $client->get('myproject/taskqueues/myqueue');
|
||||
* ```
|
||||
*/
|
||||
class ApplicationDefaultCredentials
|
||||
{
|
||||
@ -74,13 +76,12 @@ class ApplicationDefaultCredentials
|
||||
* this does not fallback to the compute engine defaults.
|
||||
*
|
||||
* @param string|array scope the scope of the access request, expressed
|
||||
* either as an Array or as a space-delimited String.
|
||||
* either as an Array or as a space-delimited String.
|
||||
* @param callable $httpHandler callback which delivers psr7 request
|
||||
* @param array $cacheConfig configuration for the cache when it's present
|
||||
* @param CacheItemPoolInterface $cache an implementation of CacheItemPoolInterface
|
||||
*
|
||||
* @param CacheItemPoolInterface $cache A cache implementation, may be
|
||||
* provided if you have one already available for use.
|
||||
* @return AuthTokenSubscriber
|
||||
*
|
||||
* @throws DomainException if no implementation can be obtained.
|
||||
*/
|
||||
public static function getSubscriber(
|
||||
@ -102,13 +103,12 @@ class ApplicationDefaultCredentials
|
||||
* this does not fallback to the compute engine defaults.
|
||||
*
|
||||
* @param string|array scope the scope of the access request, expressed
|
||||
* either as an Array or as a space-delimited String.
|
||||
* either as an Array or as a space-delimited String.
|
||||
* @param callable $httpHandler callback which delivers psr7 request
|
||||
* @param array $cacheConfig configuration for the cache when it's present
|
||||
* @param CacheItemPoolInterface $cache
|
||||
*
|
||||
* @param CacheItemPoolInterface $cache A cache implementation, may be
|
||||
* provided if you have one already available for use.
|
||||
* @return AuthTokenMiddleware
|
||||
*
|
||||
* @throws DomainException if no implementation can be obtained.
|
||||
*/
|
||||
public static function getMiddleware(
|
||||
@ -131,20 +131,23 @@ class ApplicationDefaultCredentials
|
||||
* this does not fallback to the Compute Engine defaults.
|
||||
*
|
||||
* @param string|array scope the scope of the access request, expressed
|
||||
* either as an Array or as a space-delimited String.
|
||||
* either as an Array or as a space-delimited String.
|
||||
* @param callable $httpHandler callback which delivers psr7 request
|
||||
* @param array $cacheConfig configuration for the cache when it's present
|
||||
* @param CacheItemPoolInterface $cache
|
||||
* @param CacheItemPoolInterface $cache A cache implementation, may be
|
||||
* provided if you have one already available for use.
|
||||
* @param string $quotaProject specifies a project to bill for access
|
||||
* charges associated with the request.
|
||||
*
|
||||
* @return CredentialsLoader
|
||||
*
|
||||
* @throws DomainException if no implementation can be obtained.
|
||||
*/
|
||||
public static function getCredentials(
|
||||
$scope = null,
|
||||
callable $httpHandler = null,
|
||||
array $cacheConfig = null,
|
||||
CacheItemPoolInterface $cache = null
|
||||
CacheItemPoolInterface $cache = null,
|
||||
$quotaProject = null
|
||||
) {
|
||||
$creds = null;
|
||||
$jsonKey = CredentialsLoader::fromEnv()
|
||||
@ -160,11 +163,12 @@ class ApplicationDefaultCredentials
|
||||
}
|
||||
|
||||
if (!is_null($jsonKey)) {
|
||||
$jsonKey['quota_project'] = $quotaProject;
|
||||
$creds = CredentialsLoader::makeCredentials($scope, $jsonKey);
|
||||
} elseif (AppIdentityCredentials::onAppEngine() && !GCECredentials::onAppEngineFlexible()) {
|
||||
$creds = new AppIdentityCredentials($scope);
|
||||
} elseif (GCECredentials::onGce($httpHandler)) {
|
||||
$creds = new GCECredentials(null, $scope);
|
||||
$creds = new GCECredentials(null, $scope, null, $quotaProject);
|
||||
}
|
||||
|
||||
if (is_null($creds)) {
|
||||
@ -187,10 +191,9 @@ class ApplicationDefaultCredentials
|
||||
* @param string $targetAudience The audience for the ID token.
|
||||
* @param callable $httpHandler callback which delivers psr7 request
|
||||
* @param array $cacheConfig configuration for the cache when it's present
|
||||
* @param CacheItemPoolInterface $cache
|
||||
*
|
||||
* @param CacheItemPoolInterface $cache A cache implementation, may be
|
||||
* provided if you have one already available for use.
|
||||
* @return AuthTokenMiddleware
|
||||
*
|
||||
* @throws DomainException if no implementation can be obtained.
|
||||
*/
|
||||
public static function getIdTokenMiddleware(
|
||||
@ -198,7 +201,6 @@ class ApplicationDefaultCredentials
|
||||
callable $httpHandler = null,
|
||||
array $cacheConfig = null,
|
||||
CacheItemPoolInterface $cache = null
|
||||
|
||||
) {
|
||||
$creds = self::getIdTokenCredentials($targetAudience, $httpHandler, $cacheConfig, $cache);
|
||||
|
||||
@ -213,10 +215,9 @@ class ApplicationDefaultCredentials
|
||||
* @param string $targetAudience The audience for the ID token.
|
||||
* @param callable $httpHandler callback which delivers psr7 request
|
||||
* @param array $cacheConfig configuration for the cache when it's present
|
||||
* @param CacheItemPoolInterface $cache
|
||||
*
|
||||
* @param CacheItemPoolInterface $cache A cache implementation, may be
|
||||
* provided if you have one already available for use.
|
||||
* @return CredentialsLoader
|
||||
*
|
||||
* @throws DomainException if no implementation can be obtained.
|
||||
* @throws InvalidArgumentException if JSON "type" key is invalid
|
||||
*/
|
||||
|
@ -62,22 +62,22 @@ class SysVCacheItemPool implements CacheItemPoolInterface
|
||||
/**
|
||||
* Create a SystemV shared memory based CacheItemPool.
|
||||
*
|
||||
* @param array $options [optional] {
|
||||
* Configuration options.
|
||||
*
|
||||
* @type int $variableKey The variable key for getting the data from
|
||||
* the shared memory. **Defaults to** 1.
|
||||
* @type string $proj The project identifier for ftok. This needs to
|
||||
* be a one character string. **Defaults to** 'A'.
|
||||
* @type int $memsize The memory size in bytes for shm_attach.
|
||||
* **Defaults to** 10000.
|
||||
* @type int $perm The permission for shm_attach. **Defaults to** 0600.
|
||||
* @param array $options [optional] Configuration options.
|
||||
* @param int $options.variableKey The variable key for getting the data from
|
||||
* the shared memory. **Defaults to** 1.
|
||||
* @param $options.proj string The project identifier for ftok. This needs to
|
||||
* be a one character string. **Defaults to** 'A'.
|
||||
* @param $options.memsize int The memory size in bytes for shm_attach.
|
||||
* **Defaults to** 10000.
|
||||
* @param $options.perm int The permission for shm_attach. **Defaults to**
|
||||
* 0600.
|
||||
*/
|
||||
public function __construct($options = [])
|
||||
{
|
||||
if (! extension_loaded('sysvshm')) {
|
||||
throw new \RuntimeException(
|
||||
'sysvshm extension is required to use this ItemPool');
|
||||
'sysvshm extension is required to use this ItemPool'
|
||||
);
|
||||
}
|
||||
$this->options = $options + [
|
||||
'variableKey' => self::VAR_KEY,
|
||||
@ -90,9 +90,6 @@ class SysVCacheItemPool implements CacheItemPoolInterface
|
||||
$this->sysvKey = ftok(__FILE__, $this->options['proj']);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getItem($key)
|
||||
{
|
||||
$this->loadItems();
|
||||
|
@ -90,7 +90,7 @@ class AppIdentityCredentials extends CredentialsLoader implements
|
||||
* SERVER_SOFTWARE environment variable (prod) or the APPENGINE_RUNTIME
|
||||
* environment variable (dev).
|
||||
*
|
||||
* @return true if this an App Engine Instance, false otherwise
|
||||
* @return bool true if this an App Engine Instance, false otherwise
|
||||
*/
|
||||
public static function onAppEngine()
|
||||
{
|
||||
@ -115,7 +115,6 @@ class AppIdentityCredentials extends CredentialsLoader implements
|
||||
* the GuzzleHttp\ClientInterface instance passed in will not be used.
|
||||
*
|
||||
* @param callable $httpHandler callback which delivers psr7 request
|
||||
*
|
||||
* @return array A set of auth related metadata, containing the following
|
||||
* keys:
|
||||
* - access_token (string)
|
||||
|
@ -18,6 +18,7 @@
|
||||
namespace Google\Auth\Credentials;
|
||||
|
||||
use Google\Auth\CredentialsLoader;
|
||||
use Google\Auth\GetQuotaProjectInterface;
|
||||
use Google\Auth\HttpHandler\HttpClientCache;
|
||||
use Google\Auth\HttpHandler\HttpHandlerFactory;
|
||||
use Google\Auth\Iam;
|
||||
@ -55,9 +56,12 @@ use InvalidArgumentException;
|
||||
*/
|
||||
class GCECredentials extends CredentialsLoader implements
|
||||
SignBlobInterface,
|
||||
ProjectIdProviderInterface
|
||||
ProjectIdProviderInterface,
|
||||
GetQuotaProjectInterface
|
||||
{
|
||||
// phpcs:disable
|
||||
const cacheKey = 'GOOGLE_AUTH_PHP_GCE';
|
||||
// phpcs:enable
|
||||
|
||||
/**
|
||||
* The metadata IP address on appengine instances.
|
||||
@ -149,19 +153,27 @@ class GCECredentials extends CredentialsLoader implements
|
||||
*/
|
||||
private $targetAudience;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $quotaProject;
|
||||
|
||||
/**
|
||||
* @param Iam $iam [optional] An IAM instance.
|
||||
* @param string|array $scope [optional] the scope of the access request,
|
||||
* expressed either as an array or as a space-delimited string.
|
||||
* @param string $targetAudience [optional] The audience for the ID token.
|
||||
* @param string $quotaProject [optional] Specifies a project to bill for access
|
||||
* charges associated with the request.
|
||||
*/
|
||||
public function __construct(Iam $iam = null, $scope = null, $targetAudience = null)
|
||||
public function __construct(Iam $iam = null, $scope = null, $targetAudience = null, $quotaProject = null)
|
||||
{
|
||||
$this->iam = $iam;
|
||||
|
||||
if ($scope && $targetAudience) {
|
||||
throw new InvalidArgumentException(
|
||||
'Scope and targetAudience cannot both be supplied');
|
||||
'Scope and targetAudience cannot both be supplied'
|
||||
);
|
||||
}
|
||||
|
||||
$tokenUri = self::getTokenUri();
|
||||
@ -174,7 +186,8 @@ class GCECredentials extends CredentialsLoader implements
|
||||
|
||||
$tokenUri = $tokenUri . '?scopes='. $scope;
|
||||
} elseif ($targetAudience) {
|
||||
$tokenUri = sprintf('http://%s/computeMetadata/%s?audience=%s',
|
||||
$tokenUri = sprintf(
|
||||
'http://%s/computeMetadata/%s?audience=%s',
|
||||
self::METADATA_IP,
|
||||
self::ID_TOKEN_URI_PATH,
|
||||
$targetAudience
|
||||
@ -183,6 +196,7 @@ class GCECredentials extends CredentialsLoader implements
|
||||
}
|
||||
|
||||
$this->tokenUri = $tokenUri;
|
||||
$this->quotaProject = $quotaProject;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -225,7 +239,7 @@ class GCECredentials extends CredentialsLoader implements
|
||||
* Determines if this an App Engine Flexible instance, by accessing the
|
||||
* GAE_INSTANCE environment variable.
|
||||
*
|
||||
* @return true if this an App Engine Flexible Instance, false otherwise
|
||||
* @return bool true if this an App Engine Flexible Instance, false otherwise
|
||||
*/
|
||||
public static function onAppEngineFlexible()
|
||||
{
|
||||
@ -456,4 +470,14 @@ class GCECredentials extends CredentialsLoader implements
|
||||
|
||||
return (string) $resp->getBody();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the quota project used for this API request
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getQuotaProject()
|
||||
{
|
||||
return $this->quotaProject;
|
||||
}
|
||||
}
|
||||
|
@ -43,11 +43,13 @@ class IAMCredentials
|
||||
{
|
||||
if (!is_string($selector)) {
|
||||
throw new \InvalidArgumentException(
|
||||
'selector must be a string');
|
||||
'selector must be a string'
|
||||
);
|
||||
}
|
||||
if (!is_string($token)) {
|
||||
throw new \InvalidArgumentException(
|
||||
'token must be a string');
|
||||
'token must be a string'
|
||||
);
|
||||
}
|
||||
|
||||
$this->selector = $selector;
|
||||
|
@ -112,18 +112,21 @@ class ServiceAccountCredentials extends CredentialsLoader implements
|
||||
}
|
||||
if (!array_key_exists('client_email', $jsonKey)) {
|
||||
throw new \InvalidArgumentException(
|
||||
'json key is missing the client_email field');
|
||||
'json key is missing the client_email field'
|
||||
);
|
||||
}
|
||||
if (!array_key_exists('private_key', $jsonKey)) {
|
||||
throw new \InvalidArgumentException(
|
||||
'json key is missing the private_key field');
|
||||
'json key is missing the private_key field'
|
||||
);
|
||||
}
|
||||
if (array_key_exists('quota_project', $jsonKey)) {
|
||||
$this->quotaProject = (string) $jsonKey['quota_project'];
|
||||
}
|
||||
if ($scope && $targetAudience) {
|
||||
throw new InvalidArgumentException(
|
||||
'Scope and targetAudience cannot both be supplied');
|
||||
'Scope and targetAudience cannot both be supplied'
|
||||
);
|
||||
}
|
||||
$additionalClaims = [];
|
||||
if ($targetAudience) {
|
||||
@ -199,7 +202,6 @@ class ServiceAccountCredentials extends CredentialsLoader implements
|
||||
* @param array $metadata metadata hashmap
|
||||
* @param string $authUri optional auth uri
|
||||
* @param callable $httpHandler callback which delivers psr7 request
|
||||
*
|
||||
* @return array updated metadata hashmap
|
||||
*/
|
||||
public function updateMetadata(
|
||||
|
@ -71,11 +71,13 @@ class ServiceAccountJwtAccessCredentials extends CredentialsLoader implements
|
||||
}
|
||||
if (!array_key_exists('client_email', $jsonKey)) {
|
||||
throw new \InvalidArgumentException(
|
||||
'json key is missing the client_email field');
|
||||
'json key is missing the client_email field'
|
||||
);
|
||||
}
|
||||
if (!array_key_exists('private_key', $jsonKey)) {
|
||||
throw new \InvalidArgumentException(
|
||||
'json key is missing the private_key field');
|
||||
'json key is missing the private_key field'
|
||||
);
|
||||
}
|
||||
if (array_key_exists('quota_project', $jsonKey)) {
|
||||
$this->quotaProject = (string) $jsonKey['quota_project'];
|
||||
@ -98,7 +100,6 @@ class ServiceAccountJwtAccessCredentials extends CredentialsLoader implements
|
||||
* @param array $metadata metadata hashmap
|
||||
* @param string $authUri optional auth uri
|
||||
* @param callable $httpHandler callback which delivers psr7 request
|
||||
*
|
||||
* @return array updated metadata hashmap
|
||||
*/
|
||||
public function updateMetadata(
|
||||
|
@ -74,15 +74,18 @@ class UserRefreshCredentials extends CredentialsLoader implements GetQuotaProjec
|
||||
}
|
||||
if (!array_key_exists('client_id', $jsonKey)) {
|
||||
throw new \InvalidArgumentException(
|
||||
'json key is missing the client_id field');
|
||||
'json key is missing the client_id field'
|
||||
);
|
||||
}
|
||||
if (!array_key_exists('client_secret', $jsonKey)) {
|
||||
throw new \InvalidArgumentException(
|
||||
'json key is missing the client_secret field');
|
||||
'json key is missing the client_secret field'
|
||||
);
|
||||
}
|
||||
if (!array_key_exists('refresh_token', $jsonKey)) {
|
||||
throw new \InvalidArgumentException(
|
||||
'json key is missing the refresh_token field');
|
||||
'json key is missing the refresh_token field'
|
||||
);
|
||||
}
|
||||
$this->auth = new OAuth2([
|
||||
'clientId' => $jsonKey['client_id'],
|
||||
@ -109,7 +112,8 @@ class UserRefreshCredentials extends CredentialsLoader implements GetQuotaProjec
|
||||
. 'To disable this warning, set '
|
||||
. self::SUPPRESS_CLOUD_SDK_CREDS_WARNING_ENV
|
||||
. ' environment variable to "true".',
|
||||
E_USER_WARNING);
|
||||
E_USER_WARNING
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ abstract class CredentialsLoader implements FetchAuthTokenInterface
|
||||
* variable GOOGLE_APPLICATION_CREDENTIALS. Return null if
|
||||
* GOOGLE_APPLICATION_CREDENTIALS is not specified.
|
||||
*
|
||||
* @return array JSON key | null
|
||||
* @return array|null JSON key | null
|
||||
*/
|
||||
public static function fromEnv()
|
||||
{
|
||||
@ -81,12 +81,13 @@ abstract class CredentialsLoader implements FetchAuthTokenInterface
|
||||
* Load a JSON key from a well known path.
|
||||
*
|
||||
* The well known path is OS dependent:
|
||||
* - windows: %APPDATA%/gcloud/application_default_credentials.json
|
||||
* - others: $HOME/.config/gcloud/application_default_credentials.json
|
||||
*
|
||||
* If the file does not exists, this returns null.
|
||||
* * windows: %APPDATA%/gcloud/application_default_credentials.json
|
||||
* * others: $HOME/.config/gcloud/application_default_credentials.json
|
||||
*
|
||||
* @return array JSON key | null
|
||||
* If the file does not exist, this returns null.
|
||||
*
|
||||
* @return array|null JSON key | null
|
||||
*/
|
||||
public static function fromWellKnownFile()
|
||||
{
|
||||
@ -108,9 +109,8 @@ abstract class CredentialsLoader implements FetchAuthTokenInterface
|
||||
* Create a new Credentials instance.
|
||||
*
|
||||
* @param string|array $scope the scope of the access request, expressed
|
||||
* either as an Array or as a space-delimited String.
|
||||
* either as an Array or as a space-delimited String.
|
||||
* @param array $jsonKey the JSON credentials.
|
||||
*
|
||||
* @return ServiceAccountCredentials|UserRefreshCredentials
|
||||
*/
|
||||
public static function makeCredentials($scope, array $jsonKey)
|
||||
@ -134,10 +134,9 @@ abstract class CredentialsLoader implements FetchAuthTokenInterface
|
||||
* Create an authorized HTTP Client from an instance of FetchAuthTokenInterface.
|
||||
*
|
||||
* @param FetchAuthTokenInterface $fetcher is used to fetch the auth token
|
||||
* @param array $httpClientOptoins (optional) Array of request options to apply.
|
||||
* @param array $httpClientOptions (optional) Array of request options to apply.
|
||||
* @param callable $httpHandler (optional) http client to fetch the token.
|
||||
* @param callable $tokenCallback (optional) function to be called when a new token is fetched.
|
||||
*
|
||||
* @return \GuzzleHttp\Client
|
||||
*/
|
||||
public static function makeHttpClient(
|
||||
@ -203,7 +202,6 @@ abstract class CredentialsLoader implements FetchAuthTokenInterface
|
||||
* @param array $metadata metadata hashmap
|
||||
* @param string $authUri optional auth uri
|
||||
* @param callable $httpHandler callback which delivers psr7 request
|
||||
*
|
||||
* @return array updated metadata hashmap
|
||||
*/
|
||||
public function updateMetadata(
|
||||
|
@ -46,6 +46,11 @@ class FetchAuthTokenCache implements
|
||||
*/
|
||||
private $cache;
|
||||
|
||||
/**
|
||||
* @param FetchAuthTokenInterface $fetcher A credentials fetcher
|
||||
* @param array $cacheConfig Configuration for the cache
|
||||
* @param CacheItemPoolInterface $cache
|
||||
*/
|
||||
public function __construct(
|
||||
FetchAuthTokenInterface $fetcher,
|
||||
array $cacheConfig = null,
|
||||
@ -66,9 +71,7 @@ class FetchAuthTokenCache implements
|
||||
* from the supplied fetcher.
|
||||
*
|
||||
* @param callable $httpHandler callback which delivers psr7 request
|
||||
*
|
||||
* @return array the response
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function fetchAuthToken(callable $httpHandler = null)
|
||||
@ -125,14 +128,14 @@ class FetchAuthTokenCache implements
|
||||
* Sign a blob using the fetcher.
|
||||
*
|
||||
* @param string $stringToSign The string to sign.
|
||||
* @param bool $forceOpenssl Require use of OpenSSL for local signing. Does
|
||||
* @param bool $forceOpenSsl Require use of OpenSSL for local signing. Does
|
||||
* not apply to signing done using external services. **Defaults to**
|
||||
* `false`.
|
||||
* @return string The resulting signature.
|
||||
* @throws \RuntimeException If the fetcher does not implement
|
||||
* `Google\Auth\SignBlobInterface`.
|
||||
*/
|
||||
public function signBlob($stringToSign, $forceOpenSsl = false)
|
||||
public function signBlob($stringToSign, $forceOpenSsl = false)
|
||||
{
|
||||
if (!$this->fetcher instanceof SignBlobInterface) {
|
||||
throw new \RuntimeException(
|
||||
|
@ -26,7 +26,6 @@ interface FetchAuthTokenInterface
|
||||
* Fetches the auth tokens based on the current state.
|
||||
*
|
||||
* @param callable $httpHandler callback which delivers psr7 request
|
||||
*
|
||||
* @return array a hash of auth tokens
|
||||
*/
|
||||
public function fetchAuthToken(callable $httpHandler = null);
|
||||
|
@ -45,7 +45,6 @@ class Guzzle5HttpHandler
|
||||
*
|
||||
* @param RequestInterface $request
|
||||
* @param array $options
|
||||
*
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function __invoke(RequestInterface $request, array $options = [])
|
||||
@ -62,7 +61,6 @@ class Guzzle5HttpHandler
|
||||
*
|
||||
* @param RequestInterface $request
|
||||
* @param array $options
|
||||
*
|
||||
* @return Promise
|
||||
*/
|
||||
public function async(RequestInterface $request, array $options = [])
|
||||
|
@ -26,7 +26,6 @@ class Guzzle6HttpHandler
|
||||
*
|
||||
* @param RequestInterface $request
|
||||
* @param array $options
|
||||
*
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function __invoke(RequestInterface $request, array $options = [])
|
||||
@ -40,7 +39,7 @@ class Guzzle6HttpHandler
|
||||
* @param RequestInterface $request
|
||||
* @param array $options
|
||||
*
|
||||
* @return \GuzzleHttp\Promise\Promise
|
||||
* @return \GuzzleHttp\Promise\PromiseInterface
|
||||
*/
|
||||
public function async(RequestInterface $request, array $options = [])
|
||||
{
|
||||
|
@ -89,7 +89,6 @@ class AuthTokenMiddleware
|
||||
* $res = $client->get('myproject/taskqueues/myqueue');
|
||||
*
|
||||
* @param callable $handler
|
||||
*
|
||||
* @return \Closure
|
||||
*/
|
||||
public function __invoke(callable $handler)
|
||||
|
@ -76,7 +76,8 @@ class ScopedAccessTokenMiddleware
|
||||
$this->tokenFunc = $tokenFunc;
|
||||
if (!(is_string($scopes) || is_array($scopes))) {
|
||||
throw new \InvalidArgumentException(
|
||||
'wants scope should be string or array');
|
||||
'wants scope should be string or array'
|
||||
);
|
||||
}
|
||||
$this->scopes = $scopes;
|
||||
|
||||
@ -119,7 +120,6 @@ class ScopedAccessTokenMiddleware
|
||||
* $res = $client->get('myproject/taskqueues/myqueue');
|
||||
*
|
||||
* @param callable $handler
|
||||
*
|
||||
* @return \Closure
|
||||
*/
|
||||
public function __invoke(callable $handler)
|
||||
|
@ -71,7 +71,6 @@ class SimpleMiddleware
|
||||
* $res = $client->get('drive/v2/rest');
|
||||
*
|
||||
* @param callable $handler
|
||||
*
|
||||
* @return \Closure
|
||||
*/
|
||||
public function __invoke(callable $handler)
|
||||
|
@ -120,7 +120,7 @@ class OAuth2 implements FetchAuthTokenInterface
|
||||
* The scope of the access request, expressed either as an Array or as a
|
||||
* space-delimited string.
|
||||
*
|
||||
* @var string
|
||||
* @var array
|
||||
*/
|
||||
private $scope;
|
||||
|
||||
@ -175,6 +175,13 @@ class OAuth2 implements FetchAuthTokenInterface
|
||||
*/
|
||||
private $signingKey;
|
||||
|
||||
/**
|
||||
* The signing key id when using assertion profile. Param kid in jwt header
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $signingKeyId;
|
||||
|
||||
/**
|
||||
* The signing algorithm when using an assertion profile.
|
||||
*
|
||||
@ -294,6 +301,9 @@ class OAuth2 implements FetchAuthTokenInterface
|
||||
* - signingKey
|
||||
* Signing key when using assertion profile
|
||||
*
|
||||
* - signingKeyId
|
||||
* Signing key id when using assertion profile
|
||||
*
|
||||
* - refreshToken
|
||||
* The refresh token associated with the access token
|
||||
* to be refreshed.
|
||||
@ -327,6 +337,7 @@ class OAuth2 implements FetchAuthTokenInterface
|
||||
'sub' => null,
|
||||
'audience' => null,
|
||||
'signingKey' => null,
|
||||
'signingKeyId' => null,
|
||||
'signingAlgorithm' => null,
|
||||
'scope' => null,
|
||||
'additionalClaims' => [],
|
||||
@ -345,6 +356,7 @@ class OAuth2 implements FetchAuthTokenInterface
|
||||
$this->setExpiry($opts['expiry']);
|
||||
$this->setAudience($opts['audience']);
|
||||
$this->setSigningKey($opts['signingKey']);
|
||||
$this->setSigningKeyId($opts['signingKeyId']);
|
||||
$this->setSigningAlgorithm($opts['signingAlgorithm']);
|
||||
$this->setScope($opts['scope']);
|
||||
$this->setExtensionParams($opts['extensionParams']);
|
||||
@ -359,11 +371,21 @@ class OAuth2 implements FetchAuthTokenInterface
|
||||
* - if present, but invalid, raises DomainException.
|
||||
* - otherwise returns the payload in the idtoken as a PHP object.
|
||||
*
|
||||
* if $publicKey is null, the key is decoded without being verified.
|
||||
* The behavior of this method varies depending on the version of
|
||||
* `firebase/php-jwt` you are using. In versions lower than 3.0.0, if
|
||||
* `$publicKey` is null, the key is decoded without being verified. In
|
||||
* newer versions, if a public key is not given, this method will throw an
|
||||
* `\InvalidArgumentException`.
|
||||
*
|
||||
* @param string $publicKey The public key to use to authenticate the token
|
||||
* @param array $allowed_algs List of supported verification algorithms
|
||||
*
|
||||
* @throws \DomainException if the token is missing an audience.
|
||||
* @throws \DomainException if the audience does not match the one set in
|
||||
* the OAuth2 class instance.
|
||||
* @throws \UnexpectedValueException If the token is invalid
|
||||
* @throws SignatureInvalidException If the signature is invalid.
|
||||
* @throws BeforeValidException If the token is not yet valid.
|
||||
* @throws ExpiredException If the token has expired.
|
||||
* @return null|object
|
||||
*/
|
||||
public function verifyIdToken($publicKey = null, $allowed_algs = array())
|
||||
@ -388,7 +410,6 @@ class OAuth2 implements FetchAuthTokenInterface
|
||||
* Obtains the encoded jwt from the instance data.
|
||||
*
|
||||
* @param array $config array optional configuration parameters
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function toJwt(array $config = [])
|
||||
@ -424,8 +445,12 @@ class OAuth2 implements FetchAuthTokenInterface
|
||||
}
|
||||
$assertion += $this->getAdditionalClaims();
|
||||
|
||||
return $this->jwtEncode($assertion, $this->getSigningKey(),
|
||||
$this->getSigningAlgorithm());
|
||||
return $this->jwtEncode(
|
||||
$assertion,
|
||||
$this->getSigningKey(),
|
||||
$this->getSigningAlgorithm(),
|
||||
$this->getSigningKeyId()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -490,7 +515,6 @@ class OAuth2 implements FetchAuthTokenInterface
|
||||
* Fetches the auth tokens based on the current state.
|
||||
*
|
||||
* @param callable $httpHandler callback which delivers psr7 request
|
||||
*
|
||||
* @return array the response
|
||||
*/
|
||||
public function fetchAuthToken(callable $httpHandler = null)
|
||||
@ -515,10 +539,6 @@ class OAuth2 implements FetchAuthTokenInterface
|
||||
*/
|
||||
public function getCacheKey()
|
||||
{
|
||||
if (is_string($this->scope)) {
|
||||
return $this->scope;
|
||||
}
|
||||
|
||||
if (is_array($this->scope)) {
|
||||
return implode(':', $this->scope);
|
||||
}
|
||||
@ -531,9 +551,7 @@ class OAuth2 implements FetchAuthTokenInterface
|
||||
* Parses the fetched tokens.
|
||||
*
|
||||
* @param ResponseInterface $resp the response.
|
||||
*
|
||||
* @return array the tokens parsed from the response body.
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function parseTokenResponse(ResponseInterface $resp)
|
||||
@ -559,12 +577,14 @@ class OAuth2 implements FetchAuthTokenInterface
|
||||
/**
|
||||
* Updates an OAuth 2.0 client.
|
||||
*
|
||||
* @example
|
||||
* client.updateToken([
|
||||
* Example:
|
||||
* ```
|
||||
* $oauth->updateToken([
|
||||
* 'refresh_token' => 'n4E9O119d',
|
||||
* 'access_token' => 'FJQbwq9',
|
||||
* 'expires_in' => 3600
|
||||
* ])
|
||||
* ]);
|
||||
* ```
|
||||
*
|
||||
* @param array $config
|
||||
* The configuration parameters related to the token.
|
||||
@ -621,16 +641,15 @@ class OAuth2 implements FetchAuthTokenInterface
|
||||
* Builds the authorization Uri that the user should be redirected to.
|
||||
*
|
||||
* @param array $config configuration options that customize the return url
|
||||
*
|
||||
* @return UriInterface the authorization Url.
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function buildFullAuthorizationUri(array $config = [])
|
||||
{
|
||||
if (is_null($this->getAuthorizationUri())) {
|
||||
throw new InvalidArgumentException(
|
||||
'requires an authorizationUri to have been set');
|
||||
'requires an authorizationUri to have been set'
|
||||
);
|
||||
}
|
||||
|
||||
$params = array_merge([
|
||||
@ -645,14 +664,16 @@ class OAuth2 implements FetchAuthTokenInterface
|
||||
// Validate the auth_params
|
||||
if (is_null($params['client_id'])) {
|
||||
throw new InvalidArgumentException(
|
||||
'missing the required client identifier');
|
||||
'missing the required client identifier'
|
||||
);
|
||||
}
|
||||
if (is_null($params['redirect_uri'])) {
|
||||
throw new InvalidArgumentException('missing the required redirect URI');
|
||||
}
|
||||
if (!empty($params['prompt']) && !empty($params['approval_prompt'])) {
|
||||
throw new InvalidArgumentException(
|
||||
'prompt and approval_prompt are mutually exclusive');
|
||||
'prompt and approval_prompt are mutually exclusive'
|
||||
);
|
||||
}
|
||||
|
||||
// Construct the uri object; return it if it is valid.
|
||||
@ -665,7 +686,8 @@ class OAuth2 implements FetchAuthTokenInterface
|
||||
|
||||
if ($result->getScheme() != 'https') {
|
||||
throw new InvalidArgumentException(
|
||||
'Authorization endpoint must be protected by TLS');
|
||||
'Authorization endpoint must be protected by TLS'
|
||||
);
|
||||
}
|
||||
|
||||
return $result;
|
||||
@ -743,7 +765,8 @@ class OAuth2 implements FetchAuthTokenInterface
|
||||
// @see https://developers.google.com/identity/sign-in/web/server-side-flow
|
||||
if ('postmessage' !== (string)$uri) {
|
||||
throw new InvalidArgumentException(
|
||||
'Redirect URI must be absolute');
|
||||
'Redirect URI must be absolute'
|
||||
);
|
||||
}
|
||||
}
|
||||
$this->redirectUri = (string)$uri;
|
||||
@ -768,7 +791,6 @@ class OAuth2 implements FetchAuthTokenInterface
|
||||
* a space-delimited String.
|
||||
*
|
||||
* @param string|array $scope
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function setScope($scope)
|
||||
@ -782,13 +804,15 @@ class OAuth2 implements FetchAuthTokenInterface
|
||||
$pos = strpos($s, ' ');
|
||||
if ($pos !== false) {
|
||||
throw new InvalidArgumentException(
|
||||
'array scope values should not contain spaces');
|
||||
'array scope values should not contain spaces'
|
||||
);
|
||||
}
|
||||
}
|
||||
$this->scope = $scope;
|
||||
} else {
|
||||
throw new InvalidArgumentException(
|
||||
'scopes should be a string or array of strings');
|
||||
'scopes should be a string or array of strings'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -828,7 +852,6 @@ class OAuth2 implements FetchAuthTokenInterface
|
||||
* Sets the current grant type.
|
||||
*
|
||||
* @param $grantType
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function setGrantType($grantType)
|
||||
@ -839,7 +862,8 @@ class OAuth2 implements FetchAuthTokenInterface
|
||||
// validate URI
|
||||
if (!$this->isAbsoluteUri($grantType)) {
|
||||
throw new InvalidArgumentException(
|
||||
'invalid grant type');
|
||||
'invalid grant type'
|
||||
);
|
||||
}
|
||||
$this->grantType = (string)$grantType;
|
||||
}
|
||||
@ -1031,6 +1055,26 @@ class OAuth2 implements FetchAuthTokenInterface
|
||||
$this->signingKey = $signingKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the signing key id when using an assertion profile.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSigningKeyId()
|
||||
{
|
||||
return $this->signingKeyId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the signing key id when using an assertion profile.
|
||||
*
|
||||
* @param string $signingKeyId
|
||||
*/
|
||||
public function setSigningKeyId($signingKeyId)
|
||||
{
|
||||
$this->signingKeyId = $signingKeyId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the signing algorithm when using an assertion profile.
|
||||
*
|
||||
@ -1287,7 +1331,6 @@ class OAuth2 implements FetchAuthTokenInterface
|
||||
* @todo handle uri as array
|
||||
*
|
||||
* @param string $uri
|
||||
*
|
||||
* @return null|UriInterface
|
||||
*/
|
||||
private function coerceUri($uri)
|
||||
@ -1303,7 +1346,6 @@ class OAuth2 implements FetchAuthTokenInterface
|
||||
* @param string $idToken
|
||||
* @param string|array|null $publicKey
|
||||
* @param array $allowedAlgs
|
||||
*
|
||||
* @return object
|
||||
*/
|
||||
private function jwtDecode($idToken, $publicKey, $allowedAlgs)
|
||||
@ -1315,14 +1357,18 @@ class OAuth2 implements FetchAuthTokenInterface
|
||||
return \JWT::decode($idToken, $publicKey, $allowedAlgs);
|
||||
}
|
||||
|
||||
private function jwtEncode($assertion, $signingKey, $signingAlgorithm)
|
||||
private function jwtEncode($assertion, $signingKey, $signingAlgorithm, $signingKeyId = null)
|
||||
{
|
||||
if (class_exists('Firebase\JWT\JWT')) {
|
||||
return \Firebase\JWT\JWT::encode($assertion, $signingKey,
|
||||
$signingAlgorithm);
|
||||
return \Firebase\JWT\JWT::encode(
|
||||
$assertion,
|
||||
$signingKey,
|
||||
$signingAlgorithm,
|
||||
$signingKeyId
|
||||
);
|
||||
}
|
||||
|
||||
return \JWT::encode($assertion, $signingKey, $signingAlgorithm);
|
||||
return \JWT::encode($assertion, $signingKey, $signingAlgorithm, $signingKeyId);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1330,7 +1376,6 @@ class OAuth2 implements FetchAuthTokenInterface
|
||||
* (RFC 3986).
|
||||
*
|
||||
* @param string $uri
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function isAbsoluteUri($uri)
|
||||
@ -1342,7 +1387,6 @@ class OAuth2 implements FetchAuthTokenInterface
|
||||
|
||||
/**
|
||||
* @param array $params
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function addClientCredentials(&$params)
|
||||
|
@ -79,21 +79,24 @@ class AuthTokenSubscriber implements SubscriberInterface
|
||||
/**
|
||||
* Updates the request with an Authorization header when auth is 'fetched_auth_token'.
|
||||
*
|
||||
* use GuzzleHttp\Client;
|
||||
* use Google\Auth\OAuth2;
|
||||
* use Google\Auth\Subscriber\AuthTokenSubscriber;
|
||||
* Example:
|
||||
* ```
|
||||
* use GuzzleHttp\Client;
|
||||
* use Google\Auth\OAuth2;
|
||||
* use Google\Auth\Subscriber\AuthTokenSubscriber;
|
||||
*
|
||||
* $config = [..<oauth config param>.];
|
||||
* $oauth2 = new OAuth2($config)
|
||||
* $subscriber = new AuthTokenSubscriber($oauth2);
|
||||
* $config = [..<oauth config param>.];
|
||||
* $oauth2 = new OAuth2($config)
|
||||
* $subscriber = new AuthTokenSubscriber($oauth2);
|
||||
*
|
||||
* $client = new Client([
|
||||
* 'base_url' => 'https://www.googleapis.com/taskqueue/v1beta2/projects/',
|
||||
* 'defaults' => ['auth' => 'google_auth']
|
||||
* ]);
|
||||
* $client->getEmitter()->attach($subscriber);
|
||||
* $client = new Client([
|
||||
* 'base_url' => 'https://www.googleapis.com/taskqueue/v1beta2/projects/',
|
||||
* 'defaults' => ['auth' => 'google_auth']
|
||||
* ]);
|
||||
* $client->getEmitter()->attach($subscriber);
|
||||
*
|
||||
* $res = $client->get('myproject/taskqueues/myqueue');
|
||||
* $res = $client->get('myproject/taskqueues/myqueue');
|
||||
* ```
|
||||
*
|
||||
* @param BeforeEvent $event
|
||||
*/
|
||||
|
@ -78,7 +78,8 @@ class ScopedAccessTokenSubscriber implements SubscriberInterface
|
||||
$this->tokenFunc = $tokenFunc;
|
||||
if (!(is_string($scopes) || is_array($scopes))) {
|
||||
throw new \InvalidArgumentException(
|
||||
'wants scope should be string or array');
|
||||
'wants scope should be string or array'
|
||||
);
|
||||
}
|
||||
$this->scopes = $scopes;
|
||||
|
||||
@ -102,28 +103,30 @@ class ScopedAccessTokenSubscriber implements SubscriberInterface
|
||||
/**
|
||||
* Updates the request with an Authorization header when auth is 'scoped'.
|
||||
*
|
||||
* E.g this could be used to authenticate using the AppEngine
|
||||
* AppIdentityService.
|
||||
* E.g this could be used to authenticate using the AppEngine AppIdentityService.
|
||||
*
|
||||
* use google\appengine\api\app_identity\AppIdentityService;
|
||||
* use Google\Auth\Subscriber\ScopedAccessTokenSubscriber;
|
||||
* use GuzzleHttp\Client;
|
||||
* Example:
|
||||
* ```
|
||||
* use google\appengine\api\app_identity\AppIdentityService;
|
||||
* use Google\Auth\Subscriber\ScopedAccessTokenSubscriber;
|
||||
* use GuzzleHttp\Client;
|
||||
*
|
||||
* $scope = 'https://www.googleapis.com/auth/taskqueue'
|
||||
* $subscriber = new ScopedAccessToken(
|
||||
* 'AppIdentityService::getAccessToken',
|
||||
* $scope,
|
||||
* ['prefix' => 'Google\Auth\ScopedAccessToken::'],
|
||||
* $cache = new Memcache()
|
||||
* );
|
||||
* $scope = 'https://www.googleapis.com/auth/taskqueue'
|
||||
* $subscriber = new ScopedAccessToken(
|
||||
* 'AppIdentityService::getAccessToken',
|
||||
* $scope,
|
||||
* ['prefix' => 'Google\Auth\ScopedAccessToken::'],
|
||||
* $cache = new Memcache()
|
||||
* );
|
||||
*
|
||||
* $client = new Client([
|
||||
* 'base_url' => 'https://www.googleapis.com/taskqueue/v1beta2/projects/',
|
||||
* 'defaults' => ['auth' => 'scoped']
|
||||
* ]);
|
||||
* $client->getEmitter()->attach($subscriber);
|
||||
* $client = new Client([
|
||||
* 'base_url' => 'https://www.googleapis.com/taskqueue/v1beta2/projects/',
|
||||
* 'defaults' => ['auth' => 'scoped']
|
||||
* ]);
|
||||
* $client->getEmitter()->attach($subscriber);
|
||||
*
|
||||
* $res = $client->get('myproject/taskqueues/myqueue');
|
||||
* $res = $client->get('myproject/taskqueues/myqueue');
|
||||
* ```
|
||||
*
|
||||
* @param BeforeEvent $event
|
||||
*/
|
||||
|
@ -62,19 +62,22 @@ class SimpleSubscriber implements SubscriberInterface
|
||||
/**
|
||||
* Updates the request query with the developer key if auth is set to simple.
|
||||
*
|
||||
* use Google\Auth\Subscriber\SimpleSubscriber;
|
||||
* use GuzzleHttp\Client;
|
||||
* Example:
|
||||
* ```
|
||||
* use Google\Auth\Subscriber\SimpleSubscriber;
|
||||
* use GuzzleHttp\Client;
|
||||
*
|
||||
* $my_key = 'is not the same as yours';
|
||||
* $subscriber = new SimpleSubscriber(['key' => $my_key]);
|
||||
* $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);
|
||||
* $client = new Client([
|
||||
* 'base_url' => 'https://www.googleapis.com/discovery/v1/',
|
||||
* 'defaults' => ['auth' => 'simple']
|
||||
* ]);
|
||||
* $client->getEmitter()->attach($subscriber);
|
||||
*
|
||||
* $res = $client->get('drive/v2/rest');
|
||||
* $res = $client->get('drive/v2/rest');
|
||||
* ```
|
||||
*
|
||||
* @param BeforeEvent $event
|
||||
*/
|
||||
|
Reference in New Issue
Block a user