Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php namespace Google; use BadMethodCallException; use DomainException; use Google\Acces..

Decoded Output download

<?php
 namespace Google; use BadMethodCallException; use DomainException; use Google\AccessToken\Revoke; use Google\AccessToken\Verify; use Google\Auth\ApplicationDefaultCredentials; use Google\Auth\Cache\MemoryCacheItemPool; use Google\Auth\Credentials\ServiceAccountCredentials; use Google\Auth\Credentials\UserRefreshCredentials; use Google\Auth\CredentialsLoader; use Google\Auth\FetchAuthTokenCache; use Google\Auth\HttpHandler\HttpHandlerFactory; use Google\Auth\OAuth2; use Google\AuthHandler\AuthHandlerFactory; use Google\Http\REST; use GuzzleHttp\Client as GuzzleClient; use GuzzleHttp\ClientInterface; use GuzzleHttp\Ring\Client\StreamHandler; use InvalidArgumentException; use LogicException; use Monolog\Handler\StreamHandler as MonologStreamHandler; use Monolog\Handler\SyslogHandler as MonologSyslogHandler; use Monolog\Logger; use Psr\Cache\CacheItemPoolInterface; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; use Psr\Log\LoggerInterface; use UnexpectedValueException; class Client { const LIBVER = "2.12.6"; const USER_AGENT_SUFFIX = "google-api-php-client/"; const OAUTH2_REVOKE_URI = "https://oauth2.googleapis.com/revoke"; const OAUTH2_TOKEN_URI = "https://oauth2.googleapis.com/token"; const OAUTH2_AUTH_URL = "https://accounts.google.com/o/oauth2/v2/auth"; const API_BASE_PATH = "https://www.googleapis.com"; private $auth; private $http; private $cache; private $token; private $config; private $logger; private $credentials; private $deferExecution = false; protected $requestedScopes = array(); public function __construct(array $config = array()) { $this->config = array_merge(array("application_name" => '', "base_path" => self::API_BASE_PATH, "client_id" => '', "client_secret" => '', "credentials" => null, "scopes" => null, "quota_project" => null, "redirect_uri" => null, "state" => null, "developer_key" => '', "use_application_default_credentials" => false, "signing_key" => null, "signing_algorithm" => null, "subject" => null, "hd" => '', "prompt" => '', "openid.realm" => '', "include_granted_scopes" => null, "login_hint" => '', "request_visible_actions" => '', "access_type" => "online", "approval_prompt" => "auto", "retry" => array(), "retry_map" => null, "cache" => null, "cache_config" => array(), "token_callback" => null, "jwt" => null, "api_format_v2" => false), $config); if (!is_null($this->config["credentials"])) { if ($this->config["credentials"] instanceof CredentialsLoader) { $this->credentials = $this->config["credentials"]; } else { $this->setAuthConfig($this->config["credentials"]); } unset($this->config["credentials"]); } if (!is_null($this->config["scopes"])) { $this->setScopes($this->config["scopes"]); unset($this->config["scopes"]); } if (is_null($this->config["token_callback"])) { $this->config["token_callback"] = function ($cacheKey, $newAccessToken) { $this->setAccessToken(array("access_token" => $newAccessToken, "expires_in" => 3600, "created" => time())); }; } if (!is_null($this->config["cache"])) { $this->setCache($this->config["cache"]); unset($this->config["cache"]); } } public function getLibraryVersion() { return self::LIBVER; } public function authenticate($code) { return $this->fetchAccessTokenWithAuthCode($code); } public function fetchAccessTokenWithAuthCode($code, $codeVerifier = null) { if (strlen($code) == 0) { throw new InvalidArgumentException("Invalid code"); } $auth = $this->getOAuth2Service(); $auth->setCode($code); $auth->setRedirectUri($this->getRedirectUri()); if ($codeVerifier) { $auth->setCodeVerifier($codeVerifier); } $httpHandler = HttpHandlerFactory::build($this->getHttpClient()); $creds = $auth->fetchAuthToken($httpHandler); if ($creds && isset($creds["access_token"])) { $creds["created"] = time(); $this->setAccessToken($creds); } return $creds; } public function refreshTokenWithAssertion() { return $this->fetchAccessTokenWithAssertion(); } public function fetchAccessTokenWithAssertion(ClientInterface $authHttp = null) { if (!$this->isUsingApplicationDefaultCredentials()) { throw new DomainException("set the JSON service account credentials using" . " Google\Client::setAuthConfig or set the path to your JSON file" . " with the "GOOGLE_APPLICATION_CREDENTIALS" environment variable" . " and call Google\Client::useApplicationDefaultCredentials to" . " refresh a token with assertion."); } $this->getLogger()->log("info", "OAuth2 access token refresh with Signed JWT assertion grants."); $credentials = $this->createApplicationDefaultCredentials(); $httpHandler = HttpHandlerFactory::build($authHttp); $creds = $credentials->fetchAuthToken($httpHandler); if ($creds && isset($creds["access_token"])) { $creds["created"] = time(); $this->setAccessToken($creds); } return $creds; } public function refreshToken($refreshToken) { return $this->fetchAccessTokenWithRefreshToken($refreshToken); } public function fetchAccessTokenWithRefreshToken($refreshToken = null) { if (null === $refreshToken) { if (!isset($this->token["refresh_token"])) { throw new LogicException("refresh token must be passed in or set as part of setAccessToken"); } $refreshToken = $this->token["refresh_token"]; } $this->getLogger()->info("OAuth2 access token refresh"); $auth = $this->getOAuth2Service(); $auth->setRefreshToken($refreshToken); $httpHandler = HttpHandlerFactory::build($this->getHttpClient()); $creds = $auth->fetchAuthToken($httpHandler); if ($creds && isset($creds["access_token"])) { $creds["created"] = time(); if (!isset($creds["refresh_token"])) { $creds["refresh_token"] = $refreshToken; } $this->setAccessToken($creds); } return $creds; } public function createAuthUrl($scope = null, array $queryParams = array()) { if (empty($scope)) { $scope = $this->prepareScopes(); } if (is_array($scope)) { $scope = implode(" ", $scope); } $approvalPrompt = $this->config["prompt"] ? null : $this->config["approval_prompt"]; $includeGrantedScopes = $this->config["include_granted_scopes"] === null ? null : var_export($this->config["include_granted_scopes"], true); $params = array_filter(array("access_type" => $this->config["access_type"], "approval_prompt" => $approvalPrompt, "hd" => $this->config["hd"], "include_granted_scopes" => $includeGrantedScopes, "login_hint" => $this->config["login_hint"], "openid.realm" => $this->config["openid.realm"], "prompt" => $this->config["prompt"], "redirect_uri" => $this->config["redirect_uri"], "response_type" => "code", "scope" => $scope, "state" => $this->config["state"])) + $queryParams; $rva = $this->config["request_visible_actions"]; if (strlen($rva) > 0 && false !== strpos($scope, "plus.login")) { $params["request_visible_actions"] = $rva; } $auth = $this->getOAuth2Service(); return (string) $auth->buildFullAuthorizationUri($params); } public function authorize(ClientInterface $http = null) { $http = $http ?: $this->getHttpClient(); $authHandler = $this->getAuthHandler(); if ($this->credentials) { return $authHandler->attachCredentials($http, $this->credentials, $this->config["token_callback"]); } if ($this->isUsingApplicationDefaultCredentials()) { $credentials = $this->createApplicationDefaultCredentials(); return $authHandler->attachCredentialsCache($http, $credentials, $this->config["token_callback"]); } if ($token = $this->getAccessToken()) { $scopes = $this->prepareScopes(); if (isset($token["refresh_token"]) && $this->isAccessTokenExpired()) { $credentials = $this->createUserRefreshCredentials($scopes, $token["refresh_token"]); return $authHandler->attachCredentials($http, $credentials, $this->config["token_callback"]); } return $authHandler->attachToken($http, $token, (array) $scopes); } if ($key = $this->config["developer_key"]) { return $authHandler->attachKey($http, $key); } return $http; } public function useApplicationDefaultCredentials($useAppCreds = true) { $this->config["use_application_default_credentials"] = $useAppCreds; } public function isUsingApplicationDefaultCredentials() { return $this->config["use_application_default_credentials"]; } public function setAccessToken($token) { if (is_string($token)) { if ($json = json_decode($token, true)) { $token = $json; } else { $token = array("access_token" => $token); } } if ($token == null) { throw new InvalidArgumentException("invalid json token"); } if (!isset($token["access_token"])) { throw new InvalidArgumentException("Invalid token format"); } $this->token = $token; } public function getAccessToken() { return $this->token; } public function getRefreshToken() { if (isset($this->token["refresh_token"])) { return $this->token["refresh_token"]; } return null; } public function isAccessTokenExpired() { if (!$this->token) { return true; } $created = 0; if (isset($this->token["created"])) { $created = $this->token["created"]; } elseif (isset($this->token["id_token"])) { $idToken = $this->token["id_token"]; if (substr_count($idToken, ".") == 2) { $parts = explode(".", $idToken); $payload = json_decode(base64_decode($parts[1]), true); if ($payload && isset($payload["iat"])) { $created = $payload["iat"]; } } } if (!isset($this->token["expires_in"])) { return true; } return $created + ($this->token["expires_in"] - 30) < time(); } public function getAuth() { throw new BadMethodCallException("This function no longer exists. See UPGRADING.md for more information"); } public function setAuth($auth) { throw new BadMethodCallException("This function no longer exists. See UPGRADING.md for more information"); } public function setClientId($clientId) { $this->config["client_id"] = $clientId; } public function getClientId() { return $this->config["client_id"]; } public function setClientSecret($clientSecret) { $this->config["client_secret"] = $clientSecret; } public function getClientSecret() { return $this->config["client_secret"]; } public function setRedirectUri($redirectUri) { $this->config["redirect_uri"] = $redirectUri; } public function getRedirectUri() { return $this->config["redirect_uri"]; } public function setState($state) { $this->config["state"] = $state; } public function setAccessType($accessType) { $this->config["access_type"] = $accessType; } public function setApprovalPrompt($approvalPrompt) { $this->config["approval_prompt"] = $approvalPrompt; } public function setLoginHint($loginHint) { $this->config["login_hint"] = $loginHint; } public function setApplicationName($applicationName) { $this->config["application_name"] = $applicationName; } public function setRequestVisibleActions($requestVisibleActions) { if (is_array($requestVisibleActions)) { $requestVisibleActions = implode(" ", $requestVisibleActions); } $this->config["request_visible_actions"] = $requestVisibleActions; } public function setDeveloperKey($developerKey) { $this->config["developer_key"] = $developerKey; } public function setHostedDomain($hd) { $this->config["hd"] = $hd; } public function setPrompt($prompt) { $this->config["prompt"] = $prompt; } public function setOpenidRealm($realm) { $this->config["openid.realm"] = $realm; } public function setIncludeGrantedScopes($include) { $this->config["include_granted_scopes"] = $include; } public function setTokenCallback(callable $tokenCallback) { $this->config["token_callback"] = $tokenCallback; } public function revokeToken($token = null) { $tokenRevoker = new Revoke($this->getHttpClient()); return $tokenRevoker->revokeToken($token ?: $this->getAccessToken()); } public function verifyIdToken($idToken = null) { $tokenVerifier = new Verify($this->getHttpClient(), $this->getCache(), $this->config["jwt"]); if (null === $idToken) { $token = $this->getAccessToken(); if (!isset($token["id_token"])) { throw new LogicException("id_token must be passed in or set as part of setAccessToken"); } $idToken = $token["id_token"]; } return $tokenVerifier->verifyIdToken($idToken, $this->getClientId()); } public function setScopes($scope_or_scopes) { $this->requestedScopes = array(); $this->addScope($scope_or_scopes); } public function addScope($scope_or_scopes) { if (is_string($scope_or_scopes) && !in_array($scope_or_scopes, $this->requestedScopes)) { $this->requestedScopes[] = $scope_or_scopes; } elseif (is_array($scope_or_scopes)) { foreach ($scope_or_scopes as $scope) { $this->addScope($scope); } } } public function getScopes() { return $this->requestedScopes; } public function prepareScopes() { if (empty($this->requestedScopes)) { return null; } return implode(" ", $this->requestedScopes); } public function execute(RequestInterface $request, $expectedClass = null) { $request = $request->withHeader("User-Agent", sprintf("%s %s%s", $this->config["application_name"], self::USER_AGENT_SUFFIX, $this->getLibraryVersion()))->withHeader("x-goog-api-client", sprintf("gl-php/%s gdcl/%s", phpversion(), $this->getLibraryVersion())); if ($this->config["api_format_v2"]) { $request = $request->withHeader("X-GOOG-API-FORMAT-VERSION", "2"); } $http = $this->authorize(); return REST::execute($http, $request, $expectedClass, $this->config["retry"], $this->config["retry_map"]); } public function setUseBatch($useBatch) { $this->setDefer($useBatch); } public function isAppEngine() { return isset($_SERVER["SERVER_SOFTWARE"]) && strpos($_SERVER["SERVER_SOFTWARE"], "Google App Engine") !== false; } public function setConfig($name, $value) { $this->config[$name] = $value; } public function getConfig($name, $default = null) { return isset($this->config[$name]) ? $this->config[$name] : $default; } public function setAuthConfigFile($file) { $this->setAuthConfig($file); } public function setAuthConfig($config) { if (is_string($config)) { if (!file_exists($config)) { throw new InvalidArgumentException(sprintf("file "%s" does not exist", $config)); } $json = file_get_contents($config); if (!($config = json_decode($json, true))) { throw new LogicException("invalid json for auth config"); } } $key = isset($config["installed"]) ? "installed" : "web"; if (isset($config["type"]) && $config["type"] == "service_account") { $this->useApplicationDefaultCredentials(); $this->setClientId($config["client_id"]); $this->config["client_email"] = $config["client_email"]; $this->config["signing_key"] = $config["private_key"]; $this->config["signing_algorithm"] = "HS256"; } elseif (isset($config[$key])) { $this->setClientId($config[$key]["client_id"]); $this->setClientSecret($config[$key]["client_secret"]); if (isset($config[$key]["redirect_uris"])) { $this->setRedirectUri($config[$key]["redirect_uris"][0]); } } else { $this->setClientId($config["client_id"]); $this->setClientSecret($config["client_secret"]); if (isset($config["redirect_uris"])) { $this->setRedirectUri($config["redirect_uris"][0]); } } } public function setSubject($subject) { $this->config["subject"] = $subject; } public function setDefer($defer) { $this->deferExecution = $defer; } public function shouldDefer() { return $this->deferExecution; } public function getOAuth2Service() { if (!isset($this->auth)) { $this->auth = $this->createOAuth2Service(); } return $this->auth; } protected function createOAuth2Service() { $auth = new OAuth2(array("clientId" => $this->getClientId(), "clientSecret" => $this->getClientSecret(), "authorizationUri" => self::OAUTH2_AUTH_URL, "tokenCredentialUri" => self::OAUTH2_TOKEN_URI, "redirectUri" => $this->getRedirectUri(), "issuer" => $this->config["client_id"], "signingKey" => $this->config["signing_key"], "signingAlgorithm" => $this->config["signing_algorithm"])); return $auth; } public function setCache(CacheItemPoolInterface $cache) { $this->cache = $cache; } public function getCache() { if (!$this->cache) { $this->cache = $this->createDefaultCache(); } return $this->cache; } public function setCacheConfig(array $cacheConfig) { $this->config["cache_config"] = $cacheConfig; } public function setLogger(LoggerInterface $logger) { $this->logger = $logger; } public function getLogger() { if (!isset($this->logger)) { $this->logger = $this->createDefaultLogger(); } return $this->logger; } protected function createDefaultLogger() { $logger = new Logger("google-api-php-client"); if ($this->isAppEngine()) { $handler = new MonologSyslogHandler("app", LOG_USER, Logger::NOTICE); } else { $handler = new MonologStreamHandler("php://stderr", Logger::NOTICE); } $logger->pushHandler($handler); return $logger; } protected function createDefaultCache() { return new MemoryCacheItemPool(); } public function setHttpClient(ClientInterface $http) { $this->http = $http; } public function getHttpClient() { if (null === $this->http) { $this->http = $this->createDefaultHttpClient(); } return $this->http; } public function setApiFormatV2($value) { $this->config["api_format_v2"] = (bool) $value; } protected function createDefaultHttpClient() { $guzzleVersion = null; if (defined("\GuzzleHttp\ClientInterface::MAJOR_VERSION")) { $guzzleVersion = ClientInterface::MAJOR_VERSION; } elseif (defined("\GuzzleHttp\ClientInterface::VERSION")) { $guzzleVersion = (int) substr(ClientInterface::VERSION, 0, 1); } if (5 === $guzzleVersion) { $options = array("base_url" => $this->config["base_path"], "defaults" => array("exceptions" => false)); if ($this->isAppEngine()) { if (class_exists(StreamHandler::class)) { $options["handler"] = new StreamHandler(); $options["defaults"]["verify"] = "/etc/ca-certificates.crt"; } } } elseif (6 === $guzzleVersion || 7 === $guzzleVersion) { $options = array("base_uri" => $this->config["base_path"], "http_errors" => false); } else { throw new LogicException("Could not find supported version of Guzzle."); } return new GuzzleClient($options); } private function createApplicationDefaultCredentials() { $scopes = $this->prepareScopes(); $sub = $this->config["subject"]; $signingKey = $this->config["signing_key"]; if ($signingKey) { $serviceAccountCredentials = array("client_id" => $this->config["client_id"], "client_email" => $this->config["client_email"], "private_key" => $signingKey, "type" => "service_account", "quota_project_id" => $this->config["quota_project"]); $credentials = CredentialsLoader::makeCredentials($scopes, $serviceAccountCredentials); } else { $credentials = ApplicationDefaultCredentials::getCredentials($scopes, null, $sub ? null : $this->config["cache_config"], $sub ? null : $this->getCache(), $this->config["quota_project"]); } if ($sub) { if (!$credentials instanceof ServiceAccountCredentials) { throw new DomainException("domain-wide authority requires service account credentials"); } $credentials->setSub($sub); } if (!$credentials instanceof FetchAuthTokenCache) { $credentials = new FetchAuthTokenCache($credentials, $this->config["cache_config"], $this->getCache()); } return $credentials; } protected function getAuthHandler() { return AuthHandlerFactory::build($this->getCache(), $this->config["cache_config"]); } private function createUserRefreshCredentials($scope, $refreshToken) { $creds = array_filter(array("client_id" => $this->getClientId(), "client_secret" => $this->getClientSecret(), "refresh_token" => $refreshToken)); return new UserRefreshCredentials($scope, $creds); } } ?>

Did this file decode correctly?

Original Code

<?php
 namespace Google; use BadMethodCallException; use DomainException; use Google\AccessToken\Revoke; use Google\AccessToken\Verify; use Google\Auth\ApplicationDefaultCredentials; use Google\Auth\Cache\MemoryCacheItemPool; use Google\Auth\Credentials\ServiceAccountCredentials; use Google\Auth\Credentials\UserRefreshCredentials; use Google\Auth\CredentialsLoader; use Google\Auth\FetchAuthTokenCache; use Google\Auth\HttpHandler\HttpHandlerFactory; use Google\Auth\OAuth2; use Google\AuthHandler\AuthHandlerFactory; use Google\Http\REST; use GuzzleHttp\Client as GuzzleClient; use GuzzleHttp\ClientInterface; use GuzzleHttp\Ring\Client\StreamHandler; use InvalidArgumentException; use LogicException; use Monolog\Handler\StreamHandler as MonologStreamHandler; use Monolog\Handler\SyslogHandler as MonologSyslogHandler; use Monolog\Logger; use Psr\Cache\CacheItemPoolInterface; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; use Psr\Log\LoggerInterface; use UnexpectedValueException; class Client { const LIBVER = "\62\x2e\x31\62\x2e\66"; const USER_AGENT_SUFFIX = "\147\x6f\x6f\x67\154\x65\x2d\x61\160\151\x2d\160\150\160\55\x63\x6c\x69\x65\156\x74\57"; const OAUTH2_REVOKE_URI = "\x68\164\x74\x70\163\x3a\x2f\57\157\141\165\x74\x68\62\56\147\x6f\x6f\147\154\x65\141\x70\151\163\56\143\157\155\57\162\x65\166\157\x6b\145"; const OAUTH2_TOKEN_URI = "\150\x74\x74\x70\x73\x3a\x2f\57\157\141\x75\x74\150\x32\x2e\x67\157\x6f\147\x6c\145\x61\160\x69\x73\x2e\143\157\x6d\x2f\x74\x6f\153\145\x6e"; const OAUTH2_AUTH_URL = "\150\x74\x74\x70\x73\72\x2f\57\x61\143\x63\157\165\x6e\x74\163\x2e\147\x6f\x6f\147\154\x65\56\143\157\x6d\x2f\157\57\157\x61\165\x74\x68\x32\57\x76\62\57\x61\165\164\x68"; const API_BASE_PATH = "\x68\x74\164\x70\x73\72\x2f\57\167\x77\x77\x2e\x67\157\x6f\x67\154\145\x61\160\x69\163\56\x63\x6f\155"; private $auth; private $http; private $cache; private $token; private $config; private $logger; private $credentials; private $deferExecution = false; protected $requestedScopes = array(); public function __construct(array $config = array()) { $this->config = array_merge(array("\x61\160\160\x6c\x69\143\x61\x74\151\157\156\137\156\x61\x6d\145" => '', "\142\x61\163\145\x5f\160\141\x74\x68" => self::API_BASE_PATH, "\x63\x6c\x69\145\156\x74\137\x69\144" => '', "\143\x6c\151\x65\x6e\164\x5f\163\145\143\162\145\164" => '', "\x63\x72\x65\144\145\156\x74\151\141\x6c\x73" => null, "\163\x63\157\x70\x65\163" => null, "\161\x75\157\164\141\137\x70\162\x6f\152\145\x63\164" => null, "\x72\x65\144\151\162\x65\x63\x74\x5f\x75\162\x69" => null, "\163\164\x61\x74\x65" => null, "\144\145\x76\145\154\x6f\x70\x65\162\137\153\145\x79" => '', "\165\x73\145\137\x61\160\160\154\x69\x63\141\164\151\157\x6e\137\144\145\146\141\165\x6c\x74\137\x63\x72\145\144\145\156\164\x69\141\x6c\x73" => false, "\163\x69\x67\x6e\151\156\147\x5f\153\145\171" => null, "\x73\x69\x67\156\x69\156\x67\x5f\x61\154\147\x6f\x72\x69\164\x68\x6d" => null, "\163\x75\142\152\x65\143\x74" => null, "\150\x64" => '', "\160\x72\157\x6d\160\x74" => '', "\157\x70\x65\x6e\151\144\x2e\162\145\141\x6c\155" => '', "\151\x6e\143\x6c\x75\144\145\x5f\147\x72\141\156\164\x65\x64\x5f\x73\143\x6f\160\x65\163" => null, "\154\157\x67\x69\156\137\150\151\156\x74" => '', "\x72\x65\161\165\x65\x73\x74\x5f\x76\x69\x73\x69\142\154\145\x5f\x61\x63\164\151\157\x6e\163" => '', "\141\143\x63\x65\163\x73\x5f\164\x79\x70\x65" => "\x6f\156\x6c\x69\156\145", "\x61\160\x70\x72\157\166\x61\x6c\x5f\x70\x72\157\x6d\x70\x74" => "\x61\x75\164\157", "\x72\145\x74\x72\x79" => array(), "\x72\x65\164\162\171\x5f\x6d\x61\160" => null, "\143\141\143\x68\145" => null, "\x63\x61\143\x68\x65\137\143\x6f\x6e\146\x69\x67" => array(), "\164\x6f\x6b\x65\156\x5f\x63\141\x6c\154\142\141\x63\x6b" => null, "\x6a\167\164" => null, "\x61\160\x69\x5f\146\x6f\x72\155\x61\x74\137\x76\x32" => false), $config); if (!is_null($this->config["\x63\162\145\x64\x65\x6e\x74\151\141\x6c\x73"])) { if ($this->config["\143\162\145\x64\x65\x6e\164\x69\141\x6c\x73"] instanceof CredentialsLoader) { $this->credentials = $this->config["\143\162\145\144\x65\x6e\x74\x69\x61\x6c\163"]; } else { $this->setAuthConfig($this->config["\x63\x72\145\144\145\x6e\164\151\x61\x6c\x73"]); } unset($this->config["\143\162\x65\144\145\156\x74\151\x61\154\x73"]); } if (!is_null($this->config["\163\x63\157\x70\x65\x73"])) { $this->setScopes($this->config["\163\143\x6f\x70\x65\163"]); unset($this->config["\163\x63\x6f\160\x65\163"]); } if (is_null($this->config["\x74\x6f\x6b\x65\156\137\143\x61\x6c\154\142\141\143\x6b"])) { $this->config["\x74\157\x6b\145\x6e\x5f\x63\141\x6c\x6c\142\x61\143\153"] = function ($cacheKey, $newAccessToken) { $this->setAccessToken(array("\x61\x63\x63\145\163\163\137\164\157\x6b\x65\156" => $newAccessToken, "\x65\x78\x70\x69\x72\x65\x73\x5f\x69\156" => 3600, "\143\x72\145\141\164\x65\x64" => time())); }; } if (!is_null($this->config["\x63\x61\x63\150\145"])) { $this->setCache($this->config["\143\141\143\x68\145"]); unset($this->config["\143\x61\143\x68\x65"]); } } public function getLibraryVersion() { return self::LIBVER; } public function authenticate($code) { return $this->fetchAccessTokenWithAuthCode($code); } public function fetchAccessTokenWithAuthCode($code, $codeVerifier = null) { if (strlen($code) == 0) { throw new InvalidArgumentException("\x49\x6e\166\x61\154\x69\x64\x20\143\157\x64\x65"); } $auth = $this->getOAuth2Service(); $auth->setCode($code); $auth->setRedirectUri($this->getRedirectUri()); if ($codeVerifier) { $auth->setCodeVerifier($codeVerifier); } $httpHandler = HttpHandlerFactory::build($this->getHttpClient()); $creds = $auth->fetchAuthToken($httpHandler); if ($creds && isset($creds["\x61\143\143\x65\x73\x73\137\x74\x6f\x6b\x65\156"])) { $creds["\143\x72\x65\141\164\145\x64"] = time(); $this->setAccessToken($creds); } return $creds; } public function refreshTokenWithAssertion() { return $this->fetchAccessTokenWithAssertion(); } public function fetchAccessTokenWithAssertion(ClientInterface $authHttp = null) { if (!$this->isUsingApplicationDefaultCredentials()) { throw new DomainException("\163\145\164\x20\x74\x68\145\40\112\123\117\116\x20\163\x65\162\166\x69\143\x65\40\141\143\143\157\165\x6e\164\40\143\x72\145\144\145\156\164\151\141\x6c\x73\x20\165\x73\x69\156\147" . "\x20\x47\x6f\157\x67\154\145\134\103\x6c\151\145\x6e\x74\72\x3a\163\145\x74\101\x75\164\x68\x43\157\x6e\x66\151\x67\x20\157\x72\40\163\145\x74\40\164\150\145\40\160\x61\x74\x68\40\x74\x6f\x20\x79\x6f\165\162\40\112\123\x4f\x4e\40\x66\x69\154\145" . "\x20\x77\151\x74\x68\40\x74\x68\x65\x20\x22\107\x4f\117\107\x4c\105\137\101\x50\x50\114\x49\x43\101\124\111\x4f\x4e\x5f\x43\122\x45\x44\105\x4e\124\x49\101\x4c\123\42\40\145\156\x76\x69\x72\x6f\156\155\145\156\164\x20\166\x61\x72\151\x61\142\154\145" . "\40\x61\156\144\40\x63\x61\154\x6c\x20\x47\x6f\157\x67\154\x65\134\x43\154\x69\145\x6e\164\x3a\72\x75\x73\145\x41\160\160\154\151\x63\x61\164\x69\157\x6e\x44\x65\146\x61\x75\x6c\x74\103\162\x65\x64\145\156\x74\151\141\154\x73\40\x74\157" . "\x20\162\x65\x66\162\x65\x73\150\40\x61\x20\x74\157\x6b\145\x6e\x20\167\x69\x74\150\x20\141\x73\x73\x65\x72\x74\x69\x6f\x6e\56"); } $this->getLogger()->log("\151\x6e\x66\157", "\117\101\165\x74\x68\x32\x20\x61\143\x63\145\163\163\x20\164\157\x6b\x65\156\x20\162\x65\146\162\x65\163\150\40\167\x69\x74\150\x20\123\151\x67\x6e\145\x64\x20\112\x57\124\40\141\163\163\145\x72\164\x69\x6f\x6e\x20\147\162\x61\156\164\x73\x2e"); $credentials = $this->createApplicationDefaultCredentials(); $httpHandler = HttpHandlerFactory::build($authHttp); $creds = $credentials->fetchAuthToken($httpHandler); if ($creds && isset($creds["\x61\x63\143\145\x73\163\137\x74\x6f\153\x65\156"])) { $creds["\x63\x72\x65\x61\164\x65\144"] = time(); $this->setAccessToken($creds); } return $creds; } public function refreshToken($refreshToken) { return $this->fetchAccessTokenWithRefreshToken($refreshToken); } public function fetchAccessTokenWithRefreshToken($refreshToken = null) { if (null === $refreshToken) { if (!isset($this->token["\x72\145\146\162\x65\x73\150\137\x74\x6f\x6b\145\x6e"])) { throw new LogicException("\162\x65\146\x72\145\163\x68\x20\164\x6f\153\145\156\x20\155\x75\x73\x74\x20\142\x65\40\160\141\x73\163\x65\144\x20\x69\156\40\157\162\40\163\x65\164\x20\141\x73\x20\x70\141\162\164\40\157\x66\40\x73\145\x74\101\x63\x63\x65\x73\x73\124\157\x6b\x65\x6e"); } $refreshToken = $this->token["\162\x65\x66\x72\x65\163\x68\x5f\x74\157\x6b\x65\x6e"]; } $this->getLogger()->info("\117\101\x75\164\x68\x32\x20\141\143\x63\x65\163\163\40\x74\157\x6b\x65\x6e\40\x72\145\146\162\x65\163\x68"); $auth = $this->getOAuth2Service(); $auth->setRefreshToken($refreshToken); $httpHandler = HttpHandlerFactory::build($this->getHttpClient()); $creds = $auth->fetchAuthToken($httpHandler); if ($creds && isset($creds["\x61\x63\x63\x65\163\x73\137\164\157\x6b\145\x6e"])) { $creds["\x63\162\145\x61\x74\x65\x64"] = time(); if (!isset($creds["\162\x65\x66\162\x65\x73\150\137\164\x6f\x6b\145\x6e"])) { $creds["\162\x65\x66\x72\145\163\x68\x5f\x74\x6f\153\145\156"] = $refreshToken; } $this->setAccessToken($creds); } return $creds; } public function createAuthUrl($scope = null, array $queryParams = array()) { if (empty($scope)) { $scope = $this->prepareScopes(); } if (is_array($scope)) { $scope = implode("\40", $scope); } $approvalPrompt = $this->config["\160\x72\x6f\155\x70\x74"] ? null : $this->config["\x61\160\x70\x72\x6f\x76\x61\154\137\x70\162\157\x6d\x70\x74"]; $includeGrantedScopes = $this->config["\x69\x6e\143\154\165\144\145\x5f\x67\162\141\156\164\145\144\137\163\143\x6f\x70\x65\x73"] === null ? null : var_export($this->config["\151\x6e\143\x6c\x75\144\145\137\147\162\x61\156\x74\145\x64\x5f\163\x63\x6f\x70\145\x73"], true); $params = array_filter(array("\x61\143\x63\x65\163\x73\x5f\x74\171\x70\145" => $this->config["\141\x63\143\145\x73\x73\x5f\x74\x79\x70\x65"], "\x61\160\x70\162\x6f\x76\x61\x6c\137\x70\162\157\155\x70\164" => $approvalPrompt, "\x68\144" => $this->config["\x68\144"], "\151\156\143\154\x75\x64\x65\137\147\x72\141\x6e\164\145\x64\x5f\x73\143\x6f\160\x65\163" => $includeGrantedScopes, "\x6c\x6f\x67\x69\156\137\150\x69\156\x74" => $this->config["\x6c\157\147\151\156\137\x68\x69\156\x74"], "\157\x70\x65\156\x69\x64\56\x72\145\x61\154\155" => $this->config["\157\x70\145\156\x69\144\56\162\145\141\154\x6d"], "\160\162\x6f\x6d\160\x74" => $this->config["\160\162\157\155\x70\164"], "\162\145\x64\151\162\x65\x63\x74\x5f\165\x72\151" => $this->config["\x72\x65\x64\151\162\x65\x63\164\x5f\165\x72\151"], "\162\x65\163\x70\157\156\x73\145\137\164\171\160\x65" => "\x63\157\x64\x65", "\x73\143\x6f\160\x65" => $scope, "\x73\164\x61\164\145" => $this->config["\163\x74\x61\164\x65"])) + $queryParams; $rva = $this->config["\x72\x65\161\x75\145\x73\164\x5f\166\151\x73\x69\142\154\x65\x5f\141\x63\x74\151\x6f\156\163"]; if (strlen($rva) > 0 && false !== strpos($scope, "\160\154\x75\163\x2e\154\x6f\x67\151\156")) { $params["\x72\x65\161\x75\x65\x73\x74\137\166\x69\x73\x69\142\154\x65\x5f\x61\x63\164\151\157\156\163"] = $rva; } $auth = $this->getOAuth2Service(); return (string) $auth->buildFullAuthorizationUri($params); } public function authorize(ClientInterface $http = null) { $http = $http ?: $this->getHttpClient(); $authHandler = $this->getAuthHandler(); if ($this->credentials) { return $authHandler->attachCredentials($http, $this->credentials, $this->config["\x74\x6f\x6b\x65\x6e\137\x63\x61\x6c\x6c\142\141\143\153"]); } if ($this->isUsingApplicationDefaultCredentials()) { $credentials = $this->createApplicationDefaultCredentials(); return $authHandler->attachCredentialsCache($http, $credentials, $this->config["\x74\157\153\145\156\x5f\x63\141\x6c\154\142\x61\143\x6b"]); } if ($token = $this->getAccessToken()) { $scopes = $this->prepareScopes(); if (isset($token["\162\145\x66\x72\145\163\150\x5f\164\x6f\153\x65\x6e"]) && $this->isAccessTokenExpired()) { $credentials = $this->createUserRefreshCredentials($scopes, $token["\162\x65\x66\162\x65\163\x68\x5f\x74\x6f\153\145\x6e"]); return $authHandler->attachCredentials($http, $credentials, $this->config["\164\157\x6b\x65\156\x5f\x63\x61\x6c\x6c\142\141\x63\153"]); } return $authHandler->attachToken($http, $token, (array) $scopes); } if ($key = $this->config["\x64\x65\166\145\154\157\160\x65\162\x5f\x6b\x65\171"]) { return $authHandler->attachKey($http, $key); } return $http; } public function useApplicationDefaultCredentials($useAppCreds = true) { $this->config["\165\163\x65\x5f\x61\160\160\x6c\151\143\x61\164\151\157\156\x5f\144\145\146\x61\x75\x6c\x74\137\143\x72\145\144\145\x6e\164\x69\141\x6c\x73"] = $useAppCreds; } public function isUsingApplicationDefaultCredentials() { return $this->config["\x75\x73\x65\x5f\x61\x70\160\154\x69\x63\141\164\151\x6f\156\137\x64\145\x66\x61\165\x6c\x74\x5f\x63\162\145\x64\x65\x6e\164\151\141\154\163"]; } public function setAccessToken($token) { if (is_string($token)) { if ($json = json_decode($token, true)) { $token = $json; } else { $token = array("\x61\143\143\x65\x73\x73\x5f\164\157\x6b\x65\x6e" => $token); } } if ($token == null) { throw new InvalidArgumentException("\151\156\166\141\154\x69\x64\x20\152\x73\157\x6e\x20\164\x6f\x6b\145\x6e"); } if (!isset($token["\x61\x63\x63\145\163\x73\137\x74\157\x6b\145\x6e"])) { throw new InvalidArgumentException("\x49\x6e\x76\x61\x6c\151\144\x20\x74\157\153\x65\x6e\40\146\x6f\162\155\141\x74"); } $this->token = $token; } public function getAccessToken() { return $this->token; } public function getRefreshToken() { if (isset($this->token["\x72\145\146\x72\x65\163\x68\x5f\x74\x6f\153\145\156"])) { return $this->token["\x72\145\x66\x72\x65\x73\x68\x5f\164\157\x6b\145\156"]; } return null; } public function isAccessTokenExpired() { if (!$this->token) { return true; } $created = 0; if (isset($this->token["\143\162\145\x61\164\145\x64"])) { $created = $this->token["\x63\x72\145\141\x74\x65\x64"]; } elseif (isset($this->token["\x69\144\137\164\x6f\x6b\x65\x6e"])) { $idToken = $this->token["\x69\144\x5f\x74\x6f\153\145\156"]; if (substr_count($idToken, "\56") == 2) { $parts = explode("\56", $idToken); $payload = json_decode(base64_decode($parts[1]), true); if ($payload && isset($payload["\151\x61\x74"])) { $created = $payload["\151\x61\x74"]; } } } if (!isset($this->token["\145\170\160\151\x72\145\163\x5f\151\x6e"])) { return true; } return $created + ($this->token["\x65\170\160\x69\x72\145\163\x5f\151\156"] - 30) < time(); } public function getAuth() { throw new BadMethodCallException("\x54\x68\151\x73\40\x66\165\156\143\164\151\x6f\156\40\x6e\157\40\154\x6f\156\x67\145\162\x20\145\x78\151\163\164\x73\56\40\x53\145\x65\40\x55\x50\107\x52\101\x44\111\116\107\56\x6d\144\x20\146\x6f\x72\40\x6d\157\x72\145\40\x69\156\x66\157\x72\x6d\141\x74\151\157\156"); } public function setAuth($auth) { throw new BadMethodCallException("\x54\150\x69\x73\40\146\165\156\x63\164\151\157\x6e\40\x6e\x6f\40\x6c\157\x6e\x67\x65\162\x20\x65\x78\x69\x73\164\x73\56\x20\123\x65\145\40\125\120\107\122\x41\x44\111\x4e\x47\x2e\x6d\x64\40\146\157\162\40\x6d\x6f\162\x65\40\x69\x6e\x66\x6f\x72\x6d\141\x74\x69\157\156"); } public function setClientId($clientId) { $this->config["\x63\154\151\x65\x6e\x74\x5f\151\144"] = $clientId; } public function getClientId() { return $this->config["\143\154\151\x65\x6e\164\x5f\x69\144"]; } public function setClientSecret($clientSecret) { $this->config["\x63\x6c\x69\x65\x6e\164\137\163\x65\x63\x72\x65\164"] = $clientSecret; } public function getClientSecret() { return $this->config["\x63\x6c\151\145\x6e\x74\137\x73\x65\x63\x72\x65\164"]; } public function setRedirectUri($redirectUri) { $this->config["\x72\x65\x64\x69\x72\145\143\164\137\165\x72\x69"] = $redirectUri; } public function getRedirectUri() { return $this->config["\162\145\144\x69\162\x65\x63\164\x5f\x75\162\x69"]; } public function setState($state) { $this->config["\163\164\141\x74\145"] = $state; } public function setAccessType($accessType) { $this->config["\141\143\x63\x65\x73\x73\x5f\x74\171\x70\x65"] = $accessType; } public function setApprovalPrompt($approvalPrompt) { $this->config["\x61\160\160\x72\157\166\x61\x6c\137\x70\x72\157\x6d\x70\x74"] = $approvalPrompt; } public function setLoginHint($loginHint) { $this->config["\x6c\157\x67\x69\x6e\137\x68\x69\x6e\x74"] = $loginHint; } public function setApplicationName($applicationName) { $this->config["\141\x70\160\x6c\x69\143\x61\164\x69\157\x6e\137\x6e\141\155\145"] = $applicationName; } public function setRequestVisibleActions($requestVisibleActions) { if (is_array($requestVisibleActions)) { $requestVisibleActions = implode("\x20", $requestVisibleActions); } $this->config["\162\x65\161\165\x65\x73\x74\137\x76\x69\163\151\142\154\x65\x5f\141\143\164\x69\x6f\156\163"] = $requestVisibleActions; } public function setDeveloperKey($developerKey) { $this->config["\x64\x65\166\145\154\x6f\160\145\x72\x5f\x6b\145\x79"] = $developerKey; } public function setHostedDomain($hd) { $this->config["\150\144"] = $hd; } public function setPrompt($prompt) { $this->config["\x70\162\x6f\x6d\x70\x74"] = $prompt; } public function setOpenidRealm($realm) { $this->config["\x6f\160\x65\156\151\144\x2e\x72\x65\x61\154\x6d"] = $realm; } public function setIncludeGrantedScopes($include) { $this->config["\x69\x6e\x63\154\x75\144\145\137\147\162\141\156\x74\145\x64\137\x73\x63\157\160\x65\163"] = $include; } public function setTokenCallback(callable $tokenCallback) { $this->config["\164\x6f\153\145\156\x5f\x63\x61\154\x6c\x62\141\x63\x6b"] = $tokenCallback; } public function revokeToken($token = null) { $tokenRevoker = new Revoke($this->getHttpClient()); return $tokenRevoker->revokeToken($token ?: $this->getAccessToken()); } public function verifyIdToken($idToken = null) { $tokenVerifier = new Verify($this->getHttpClient(), $this->getCache(), $this->config["\x6a\x77\164"]); if (null === $idToken) { $token = $this->getAccessToken(); if (!isset($token["\151\x64\x5f\x74\157\x6b\145\156"])) { throw new LogicException("\151\x64\x5f\x74\x6f\153\145\156\40\155\x75\x73\x74\x20\x62\145\x20\160\141\x73\x73\x65\x64\x20\151\156\40\x6f\162\x20\163\145\x74\x20\x61\x73\40\160\141\162\164\40\x6f\x66\40\x73\x65\164\101\143\x63\145\163\x73\124\157\x6b\145\156"); } $idToken = $token["\151\144\x5f\164\x6f\x6b\x65\156"]; } return $tokenVerifier->verifyIdToken($idToken, $this->getClientId()); } public function setScopes($scope_or_scopes) { $this->requestedScopes = array(); $this->addScope($scope_or_scopes); } public function addScope($scope_or_scopes) { if (is_string($scope_or_scopes) && !in_array($scope_or_scopes, $this->requestedScopes)) { $this->requestedScopes[] = $scope_or_scopes; } elseif (is_array($scope_or_scopes)) { foreach ($scope_or_scopes as $scope) { $this->addScope($scope); } } } public function getScopes() { return $this->requestedScopes; } public function prepareScopes() { if (empty($this->requestedScopes)) { return null; } return implode("\x20", $this->requestedScopes); } public function execute(RequestInterface $request, $expectedClass = null) { $request = $request->withHeader("\125\x73\145\x72\55\x41\147\x65\156\164", sprintf("\x25\x73\40\45\x73\45\163", $this->config["\x61\x70\x70\x6c\151\x63\x61\164\151\x6f\x6e\137\156\x61\x6d\x65"], self::USER_AGENT_SUFFIX, $this->getLibraryVersion()))->withHeader("\170\55\x67\157\x6f\x67\x2d\141\160\x69\55\x63\154\151\145\156\164", sprintf("\147\154\55\x70\x68\160\57\x25\x73\x20\147\x64\x63\154\57\x25\163", phpversion(), $this->getLibraryVersion())); if ($this->config["\141\160\x69\x5f\146\157\162\155\x61\x74\137\166\62"]) { $request = $request->withHeader("\x58\x2d\107\x4f\x4f\x47\x2d\101\x50\111\x2d\106\117\x52\115\101\124\55\126\x45\122\123\x49\117\116", "\62"); } $http = $this->authorize(); return REST::execute($http, $request, $expectedClass, $this->config["\x72\x65\x74\x72\171"], $this->config["\162\x65\164\162\x79\137\155\141\160"]); } public function setUseBatch($useBatch) { $this->setDefer($useBatch); } public function isAppEngine() { return isset($_SERVER["\x53\x45\122\126\x45\122\x5f\x53\x4f\106\124\x57\101\x52\105"]) && strpos($_SERVER["\x53\x45\122\126\105\122\137\x53\117\106\124\127\101\122\x45"], "\107\157\x6f\147\x6c\x65\40\101\x70\x70\40\105\156\147\151\x6e\x65") !== false; } public function setConfig($name, $value) { $this->config[$name] = $value; } public function getConfig($name, $default = null) { return isset($this->config[$name]) ? $this->config[$name] : $default; } public function setAuthConfigFile($file) { $this->setAuthConfig($file); } public function setAuthConfig($config) { if (is_string($config)) { if (!file_exists($config)) { throw new InvalidArgumentException(sprintf("\x66\151\x6c\145\40\x22\x25\x73\42\40\144\157\145\163\40\156\x6f\164\x20\145\x78\151\x73\x74", $config)); } $json = file_get_contents($config); if (!($config = json_decode($json, true))) { throw new LogicException("\x69\156\x76\141\154\x69\144\40\x6a\163\157\x6e\40\x66\157\x72\x20\141\x75\x74\x68\40\x63\x6f\x6e\146\151\147"); } } $key = isset($config["\151\x6e\163\x74\x61\x6c\154\x65\144"]) ? "\x69\x6e\x73\x74\141\x6c\x6c\145\144" : "\x77\145\x62"; if (isset($config["\x74\171\160\x65"]) && $config["\x74\x79\x70\145"] == "\x73\x65\162\x76\x69\x63\145\137\141\x63\x63\x6f\165\156\x74") { $this->useApplicationDefaultCredentials(); $this->setClientId($config["\x63\154\151\x65\x6e\x74\137\151\144"]); $this->config["\x63\154\151\145\156\164\137\x65\x6d\141\151\154"] = $config["\x63\154\x69\x65\156\x74\x5f\x65\155\x61\x69\154"]; $this->config["\x73\151\147\x6e\x69\x6e\x67\x5f\153\x65\x79"] = $config["\160\162\x69\166\x61\x74\145\137\x6b\x65\171"]; $this->config["\x73\151\x67\156\x69\156\x67\x5f\x61\x6c\147\157\x72\x69\164\x68\x6d"] = "\110\123\x32\65\66"; } elseif (isset($config[$key])) { $this->setClientId($config[$key]["\143\x6c\x69\x65\x6e\164\137\x69\144"]); $this->setClientSecret($config[$key]["\x63\x6c\151\145\156\164\x5f\163\145\x63\x72\145\x74"]); if (isset($config[$key]["\162\145\x64\151\162\x65\143\x74\x5f\165\x72\x69\163"])) { $this->setRedirectUri($config[$key]["\162\145\x64\151\x72\x65\x63\x74\137\x75\162\151\163"][0]); } } else { $this->setClientId($config["\143\154\151\145\x6e\164\x5f\151\x64"]); $this->setClientSecret($config["\x63\x6c\x69\x65\156\x74\x5f\163\145\x63\x72\145\x74"]); if (isset($config["\x72\x65\x64\151\x72\x65\143\x74\x5f\165\162\151\163"])) { $this->setRedirectUri($config["\x72\145\144\x69\162\145\x63\164\x5f\x75\x72\x69\163"][0]); } } } public function setSubject($subject) { $this->config["\x73\x75\x62\x6a\x65\143\x74"] = $subject; } public function setDefer($defer) { $this->deferExecution = $defer; } public function shouldDefer() { return $this->deferExecution; } public function getOAuth2Service() { if (!isset($this->auth)) { $this->auth = $this->createOAuth2Service(); } return $this->auth; } protected function createOAuth2Service() { $auth = new OAuth2(array("\143\x6c\x69\x65\156\164\111\x64" => $this->getClientId(), "\143\x6c\151\x65\156\164\123\x65\143\162\145\x74" => $this->getClientSecret(), "\141\x75\164\x68\x6f\x72\151\172\x61\x74\x69\157\156\125\x72\x69" => self::OAUTH2_AUTH_URL, "\x74\x6f\x6b\145\x6e\x43\x72\145\144\145\x6e\x74\151\x61\x6c\125\162\x69" => self::OAUTH2_TOKEN_URI, "\162\145\x64\151\162\145\x63\164\x55\162\x69" => $this->getRedirectUri(), "\x69\x73\x73\165\x65\x72" => $this->config["\x63\154\151\145\x6e\x74\x5f\151\x64"], "\163\151\147\x6e\x69\156\147\x4b\145\x79" => $this->config["\163\x69\x67\x6e\151\156\147\137\153\x65\x79"], "\163\x69\147\156\x69\x6e\147\x41\x6c\147\x6f\x72\x69\x74\x68\155" => $this->config["\x73\x69\147\x6e\151\x6e\x67\x5f\141\x6c\147\157\x72\151\164\x68\155"])); return $auth; } public function setCache(CacheItemPoolInterface $cache) { $this->cache = $cache; } public function getCache() { if (!$this->cache) { $this->cache = $this->createDefaultCache(); } return $this->cache; } public function setCacheConfig(array $cacheConfig) { $this->config["\143\x61\143\150\x65\137\143\157\x6e\x66\x69\147"] = $cacheConfig; } public function setLogger(LoggerInterface $logger) { $this->logger = $logger; } public function getLogger() { if (!isset($this->logger)) { $this->logger = $this->createDefaultLogger(); } return $this->logger; } protected function createDefaultLogger() { $logger = new Logger("\x67\x6f\x6f\x67\x6c\145\55\x61\160\151\55\160\x68\x70\55\143\x6c\151\145\156\164"); if ($this->isAppEngine()) { $handler = new MonologSyslogHandler("\141\x70\x70", LOG_USER, Logger::NOTICE); } else { $handler = new MonologStreamHandler("\160\150\160\72\x2f\57\x73\x74\x64\x65\162\162", Logger::NOTICE); } $logger->pushHandler($handler); return $logger; } protected function createDefaultCache() { return new MemoryCacheItemPool(); } public function setHttpClient(ClientInterface $http) { $this->http = $http; } public function getHttpClient() { if (null === $this->http) { $this->http = $this->createDefaultHttpClient(); } return $this->http; } public function setApiFormatV2($value) { $this->config["\x61\160\151\137\x66\157\162\x6d\x61\164\137\166\62"] = (bool) $value; } protected function createDefaultHttpClient() { $guzzleVersion = null; if (defined("\134\x47\165\172\x7a\154\x65\110\x74\164\160\134\103\x6c\x69\x65\x6e\164\x49\156\x74\x65\x72\x66\141\x63\145\72\x3a\115\101\112\117\x52\x5f\126\105\x52\123\x49\x4f\x4e")) { $guzzleVersion = ClientInterface::MAJOR_VERSION; } elseif (defined("\x5c\107\x75\172\x7a\154\x65\110\164\164\x70\134\x43\154\x69\x65\156\x74\x49\156\164\145\162\x66\x61\x63\145\72\72\x56\x45\122\x53\111\117\116")) { $guzzleVersion = (int) substr(ClientInterface::VERSION, 0, 1); } if (5 === $guzzleVersion) { $options = array("\x62\141\163\145\137\165\x72\x6c" => $this->config["\142\141\163\x65\x5f\160\x61\x74\x68"], "\144\145\146\141\165\154\164\163" => array("\x65\170\143\145\x70\164\x69\x6f\156\x73" => false)); if ($this->isAppEngine()) { if (class_exists(StreamHandler::class)) { $options["\x68\x61\x6e\x64\154\x65\x72"] = new StreamHandler(); $options["\x64\x65\x66\141\x75\154\164\x73"]["\166\x65\162\x69\x66\171"] = "\x2f\145\164\x63\x2f\x63\x61\x2d\143\145\162\164\x69\x66\x69\x63\141\x74\x65\x73\x2e\x63\162\x74"; } } } elseif (6 === $guzzleVersion || 7 === $guzzleVersion) { $options = array("\142\141\163\x65\x5f\x75\x72\x69" => $this->config["\142\141\163\x65\137\x70\x61\164\x68"], "\150\164\x74\x70\x5f\145\162\x72\157\x72\163" => false); } else { throw new LogicException("\103\x6f\x75\x6c\x64\40\x6e\x6f\164\x20\x66\151\156\x64\40\x73\165\160\160\157\x72\164\x65\144\x20\166\x65\162\163\151\x6f\156\40\x6f\146\40\107\165\x7a\x7a\x6c\x65\x2e"); } return new GuzzleClient($options); } private function createApplicationDefaultCredentials() { $scopes = $this->prepareScopes(); $sub = $this->config["\x73\165\142\x6a\x65\x63\x74"]; $signingKey = $this->config["\x73\x69\147\x6e\151\x6e\147\137\153\x65\171"]; if ($signingKey) { $serviceAccountCredentials = array("\x63\x6c\x69\145\x6e\x74\x5f\151\144" => $this->config["\x63\154\x69\x65\156\x74\x5f\151\144"], "\x63\x6c\151\x65\x6e\164\137\x65\x6d\x61\151\x6c" => $this->config["\143\154\151\x65\x6e\x74\x5f\145\155\141\151\x6c"], "\x70\x72\x69\x76\141\164\145\137\153\x65\171" => $signingKey, "\164\x79\160\145" => "\x73\145\x72\x76\151\x63\145\x5f\x61\143\x63\157\165\156\164", "\x71\165\x6f\x74\141\x5f\x70\x72\x6f\x6a\145\x63\164\137\151\144" => $this->config["\x71\x75\x6f\164\141\137\160\162\157\x6a\145\143\x74"]); $credentials = CredentialsLoader::makeCredentials($scopes, $serviceAccountCredentials); } else { $credentials = ApplicationDefaultCredentials::getCredentials($scopes, null, $sub ? null : $this->config["\143\x61\143\150\x65\x5f\143\157\156\146\151\147"], $sub ? null : $this->getCache(), $this->config["\161\x75\157\164\x61\137\160\x72\157\152\145\x63\x74"]); } if ($sub) { if (!$credentials instanceof ServiceAccountCredentials) { throw new DomainException("\x64\157\155\141\x69\156\55\x77\x69\144\x65\x20\x61\165\x74\x68\157\162\x69\164\171\40\x72\x65\x71\x75\151\x72\145\x73\40\163\145\x72\166\151\143\x65\x20\x61\143\x63\x6f\x75\x6e\164\x20\x63\x72\145\144\145\156\164\x69\141\x6c\163"); } $credentials->setSub($sub); } if (!$credentials instanceof FetchAuthTokenCache) { $credentials = new FetchAuthTokenCache($credentials, $this->config["\x63\141\143\x68\x65\x5f\143\157\156\146\151\147"], $this->getCache()); } return $credentials; } protected function getAuthHandler() { return AuthHandlerFactory::build($this->getCache(), $this->config["\143\141\x63\x68\x65\137\x63\x6f\x6e\146\x69\147"]); } private function createUserRefreshCredentials($scope, $refreshToken) { $creds = array_filter(array("\143\x6c\x69\x65\156\164\137\151\x64" => $this->getClientId(), "\143\154\x69\x65\x6e\164\137\x73\x65\x63\162\145\x74" => $this->getClientSecret(), "\162\x65\x66\x72\145\x73\x68\x5f\x74\x6f\x6b\145\156" => $refreshToken)); return new UserRefreshCredentials($scope, $creds); } }

Function Calls

None

Variables

None

Stats

MD5 fcf7c2641541037c3673fbbcbaf5bc12
Eval Count 0
Decode Time 133 ms