first commit

This commit is contained in:
2026-03-05 13:07:40 +01:00
commit 64ba0721ee
25709 changed files with 4691006 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
<?php
// autoload.php @generated by Composer
require_once __DIR__ . '/composer/autoload_real.php';
return ComposerAutoloaderInit381ef710b1ae857a1b0cca4550c7cd7e::getLoader();

View File

@@ -0,0 +1,445 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Autoload;
/**
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
*
* $loader = new \Composer\Autoload\ClassLoader();
*
* // register classes with namespaces
* $loader->add('Symfony\Component', __DIR__.'/component');
* $loader->add('Symfony', __DIR__.'/framework');
*
* // activate the autoloader
* $loader->register();
*
* // to enable searching the include path (eg. for PEAR packages)
* $loader->setUseIncludePath(true);
*
* In this example, if you try to use a class in the Symfony\Component
* namespace or one of its children (Symfony\Component\Console for instance),
* the autoloader will first look for the class under the component/
* directory, and it will then fallback to the framework/ directory if not
* found before giving up.
*
* This class is loosely based on the Symfony UniversalClassLoader.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Jordi Boggiano <j.boggiano@seld.be>
* @see http://www.php-fig.org/psr/psr-0/
* @see http://www.php-fig.org/psr/psr-4/
*/
class ClassLoader
{
// PSR-4
private $prefixLengthsPsr4 = array();
private $prefixDirsPsr4 = array();
private $fallbackDirsPsr4 = array();
// PSR-0
private $prefixesPsr0 = array();
private $fallbackDirsPsr0 = array();
private $useIncludePath = false;
private $classMap = array();
private $classMapAuthoritative = false;
private $missingClasses = array();
private $apcuPrefix;
public function getPrefixes()
{
if (!empty($this->prefixesPsr0)) {
return call_user_func_array('array_merge', $this->prefixesPsr0);
}
return array();
}
public function getPrefixesPsr4()
{
return $this->prefixDirsPsr4;
}
public function getFallbackDirs()
{
return $this->fallbackDirsPsr0;
}
public function getFallbackDirsPsr4()
{
return $this->fallbackDirsPsr4;
}
public function getClassMap()
{
return $this->classMap;
}
/**
* @param array $classMap Class to filename map
*/
public function addClassMap(array $classMap)
{
if ($this->classMap) {
$this->classMap = array_merge($this->classMap, $classMap);
} else {
$this->classMap = $classMap;
}
}
/**
* Registers a set of PSR-0 directories for a given prefix, either
* appending or prepending to the ones previously set for this prefix.
*
* @param string $prefix The prefix
* @param array|string $paths The PSR-0 root directories
* @param bool $prepend Whether to prepend the directories
*/
public function add($prefix, $paths, $prepend = false)
{
if (!$prefix) {
if ($prepend) {
$this->fallbackDirsPsr0 = array_merge(
(array) $paths,
$this->fallbackDirsPsr0
);
} else {
$this->fallbackDirsPsr0 = array_merge(
$this->fallbackDirsPsr0,
(array) $paths
);
}
return;
}
$first = $prefix[0];
if (!isset($this->prefixesPsr0[$first][$prefix])) {
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
return;
}
if ($prepend) {
$this->prefixesPsr0[$first][$prefix] = array_merge(
(array) $paths,
$this->prefixesPsr0[$first][$prefix]
);
} else {
$this->prefixesPsr0[$first][$prefix] = array_merge(
$this->prefixesPsr0[$first][$prefix],
(array) $paths
);
}
}
/**
* Registers a set of PSR-4 directories for a given namespace, either
* appending or prepending to the ones previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param array|string $paths The PSR-4 base directories
* @param bool $prepend Whether to prepend the directories
*
* @throws \InvalidArgumentException
*/
public function addPsr4($prefix, $paths, $prepend = false)
{
if (!$prefix) {
// Register directories for the root namespace.
if ($prepend) {
$this->fallbackDirsPsr4 = array_merge(
(array) $paths,
$this->fallbackDirsPsr4
);
} else {
$this->fallbackDirsPsr4 = array_merge(
$this->fallbackDirsPsr4,
(array) $paths
);
}
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
// Register directories for a new namespace.
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
} elseif ($prepend) {
// Prepend directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
(array) $paths,
$this->prefixDirsPsr4[$prefix]
);
} else {
// Append directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
$this->prefixDirsPsr4[$prefix],
(array) $paths
);
}
}
/**
* Registers a set of PSR-0 directories for a given prefix,
* replacing any others previously set for this prefix.
*
* @param string $prefix The prefix
* @param array|string $paths The PSR-0 base directories
*/
public function set($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr0 = (array) $paths;
} else {
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
}
}
/**
* Registers a set of PSR-4 directories for a given namespace,
* replacing any others previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param array|string $paths The PSR-4 base directories
*
* @throws \InvalidArgumentException
*/
public function setPsr4($prefix, $paths)
{
if (!$prefix) {
$this->fallbackDirsPsr4 = (array) $paths;
} else {
$length = strlen($prefix);
if ('\\' !== $prefix[$length - 1]) {
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
}
}
/**
* Turns on searching the include path for class files.
*
* @param bool $useIncludePath
*/
public function setUseIncludePath($useIncludePath)
{
$this->useIncludePath = $useIncludePath;
}
/**
* Can be used to check if the autoloader uses the include path to check
* for classes.
*
* @return bool
*/
public function getUseIncludePath()
{
return $this->useIncludePath;
}
/**
* Turns off searching the prefix and fallback directories for classes
* that have not been registered with the class map.
*
* @param bool $classMapAuthoritative
*/
public function setClassMapAuthoritative($classMapAuthoritative)
{
$this->classMapAuthoritative = $classMapAuthoritative;
}
/**
* Should class lookup fail if not found in the current class map?
*
* @return bool
*/
public function isClassMapAuthoritative()
{
return $this->classMapAuthoritative;
}
/**
* APCu prefix to use to cache found/not-found classes, if the extension is enabled.
*
* @param string|null $apcuPrefix
*/
public function setApcuPrefix($apcuPrefix)
{
$this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null;
}
/**
* The APCu prefix in use, or null if APCu caching is not enabled.
*
* @return string|null
*/
public function getApcuPrefix()
{
return $this->apcuPrefix;
}
/**
* Registers this instance as an autoloader.
*
* @param bool $prepend Whether to prepend the autoloader or not
*/
public function register($prepend = false)
{
spl_autoload_register(array($this, 'loadClass'), true, $prepend);
}
/**
* Unregisters this instance as an autoloader.
*/
public function unregister()
{
spl_autoload_unregister(array($this, 'loadClass'));
}
/**
* Loads the given class or interface.
*
* @param string $class The name of the class
* @return bool|null True if loaded, null otherwise
*/
public function loadClass($class)
{
if ($file = $this->findFile($class)) {
includeFile($file);
return true;
}
}
/**
* Finds the path to the file where the class is defined.
*
* @param string $class The name of the class
*
* @return string|false The path if found, false otherwise
*/
public function findFile($class)
{
// class map lookup
if (isset($this->classMap[$class])) {
return $this->classMap[$class];
}
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
return false;
}
if (null !== $this->apcuPrefix) {
$file = apcu_fetch($this->apcuPrefix.$class, $hit);
if ($hit) {
return $file;
}
}
$file = $this->findFileWithExtension($class, '.php');
// Search for Hack files if we are running on HHVM
if (false === $file && defined('HHVM_VERSION')) {
$file = $this->findFileWithExtension($class, '.hh');
}
if (null !== $this->apcuPrefix) {
apcu_add($this->apcuPrefix.$class, $file);
}
if (false === $file) {
// Remember that this class does not exist.
$this->missingClasses[$class] = true;
}
return $file;
}
private function findFileWithExtension($class, $ext)
{
// PSR-4 lookup
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
$first = $class[0];
if (isset($this->prefixLengthsPsr4[$first])) {
$subPath = $class;
while (false !== $lastPos = strrpos($subPath, '\\')) {
$subPath = substr($subPath, 0, $lastPos);
$search = $subPath . '\\';
if (isset($this->prefixDirsPsr4[$search])) {
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
foreach ($this->prefixDirsPsr4[$search] as $dir) {
if (file_exists($file = $dir . $pathEnd)) {
return $file;
}
}
}
}
}
// PSR-4 fallback dirs
foreach ($this->fallbackDirsPsr4 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
return $file;
}
}
// PSR-0 lookup
if (false !== $pos = strrpos($class, '\\')) {
// namespaced class name
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
} else {
// PEAR-like class name
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
}
if (isset($this->prefixesPsr0[$first])) {
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
if (0 === strpos($class, $prefix)) {
foreach ($dirs as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
}
}
}
// PSR-0 fallback dirs
foreach ($this->fallbackDirsPsr0 as $dir) {
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
return $file;
}
}
// PSR-0 include paths.
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
return $file;
}
return false;
}
}
/**
* Scope isolated include.
*
* Prevents access to $this/self from included files.
*/
function includeFile($file)
{
include $file;
}

View File

@@ -0,0 +1,21 @@
Copyright (c) Nils Adermann, Jordi Boggiano
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,13 @@
<?php
// autoload_classmap.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'Google_Service_Exception' => $baseDir . '/includes/lib/google-api-php-client/src/Google/Service/Exception.php',
'Google_Service_Resource' => $baseDir . '/includes/lib/google-api-php-client/src/Google/Service/Resource.php',
'WPvivid_Google_Service_Exception' => $baseDir . '/includes/lib2/google-api-php-client/src/WPvivid/Google/Service/Exception.php',
'WPvivid_Google_Service_Resource' => $baseDir . '/includes/lib2/google-api-php-client/src/WPvivid/Google/Service/Resource.php',
);

View File

@@ -0,0 +1,36 @@
<?php
// autoload_files.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
if (PHP_VERSION_ID < 50500)
{
return array(
//'7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php',
//'decc78cc4436b1292c6c0d151b19445c' => $vendorDir . '/phpseclib/phpseclib/phpseclib/bootstrap.php',
//'3919eeb97e98d4648304477f8ef734ba' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Random.php',
'7b11c4dc42b3b3023073cb14e519684c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php',
'decc78cc4436b1292c6c0d151b19446c' => $vendorDir . '/phpseclib/phpseclib/phpseclib/bootstrap.php',
'3919eeb97e98d4648304477f8ef735ba' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Random.php',
);
}
else
{
return array(
//'7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php',
//'c964ee0ededf28c96ebd9db5099ef910' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php',
//'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php',
//'37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
//'decc78cc4436b1292c6c0d151b19445c' => $vendorDir . '/phpseclib/phpseclib/phpseclib/bootstrap.php',
//'3919eeb97e98d4648304477f8ef734ba' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Random.php',
'7b11c4dc42b3b3023073cb14e519684c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php',
'c964ee0ededf28c96ebd9db5099ef911' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php',
'a0edc8309cc5e1d60e3047b5df6b7057' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php',
'37a3dc5111fe8f707ab4c132ef1dbc63' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
'decc78cc4436b1292c6c0d151b19446c' => $vendorDir . '/phpseclib/phpseclib/phpseclib/bootstrap.php',
'3919eeb97e98d4648304477f8ef735ba' => $vendorDir . '/phpseclib/phpseclib/phpseclib/Crypt/Random.php',
);
}

View File

@@ -0,0 +1,20 @@
<?php
// autoload_namespaces.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'System' => array($vendorDir . '/phpseclib/phpseclib/phpseclib'),
'Net' => array($vendorDir . '/phpseclib/phpseclib/phpseclib'),
'Math' => array($vendorDir . '/phpseclib/phpseclib/phpseclib'),
'Guzzle\\Tests' => array($vendorDir . '/guzzle/guzzle/tests'),
'Guzzle' => array($vendorDir . '/guzzle/guzzle/src'),
'Google_Service_' => array($vendorDir . '/google/apiclient-services/src'),
'Google_' => array($baseDir . '/includes/lib/google-api-php-client/src'),
'WPvivid_Google_' => array($baseDir . '/includes/lib2/google-api-php-client/src'),
'File' => array($vendorDir . '/phpseclib/phpseclib/phpseclib'),
'Crypt' => array($vendorDir . '/phpseclib/phpseclib/phpseclib'),
'Aws' => array($baseDir . '/includes/lib/aws-sdk-php-2.8.31/src'),
);

View File

@@ -0,0 +1,19 @@
<?php
// autoload_psr4.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
'Symfony\\Component\\EventDispatcher\\' => array($vendorDir . '/symfony/event-dispatcher'),
'WPvividPsr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'),
'WPvividPsr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src'),
'WPvividPsr\\Cache\\' => array($vendorDir . '/psr/cache/src'),
'WPvividMonolog\\' => array($vendorDir . '/monolog/monolog/src/Monolog'),
'WPvividGuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'),
'WPvividGuzzleHttp\\Promise\\' => array($vendorDir . '/guzzlehttp/promises/src'),
'WPvividGuzzleHttp\\' => array($vendorDir . '/guzzlehttp/guzzle/src'),
'WPvividGoogle\\Auth\\' => array($vendorDir . '/google/auth/src'),
'Firebase\\JWT\\' => array($vendorDir . '/firebase/php-jwt/src'),
);

View File

@@ -0,0 +1,74 @@
<?php
// autoload_real.php @generated by Composer
class ComposerAutoloaderInit381ef710b1ae857a1b0cca4550c7cd7e
{
private static $loader;
public static function loadClassLoader($class)
{
if ('Composer\Autoload\ClassLoader' === $class) {
require __DIR__ . '/ClassLoader.php';
}
}
public static function getLoader()
{
if (null !== self::$loader) {
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInit381ef710b1ae857a1b0cca4550c7cd7e', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInit381ef710b1ae857a1b0cca4550c7cd7e', 'loadClassLoader'));
$includePaths = require __DIR__ . '/include_paths.php';
$includePaths[] = get_include_path();
set_include_path(implode(PATH_SEPARATOR, $includePaths));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php';
call_user_func(\Composer\Autoload\ComposerStaticInit381ef710b1ae857a1b0cca4550c7cd7e::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
$loader->set($namespace, $path);
}
$map = require __DIR__ . '/autoload_psr4.php';
foreach ($map as $namespace => $path) {
$loader->setPsr4($namespace, $path);
}
$classMap = require __DIR__ . '/autoload_classmap.php';
if ($classMap) {
$loader->addClassMap($classMap);
}
}
$loader->register(false);
if ($useStaticLoader) {
$includeFiles = Composer\Autoload\ComposerStaticInit381ef710b1ae857a1b0cca4550c7cd7e::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequire381ef710b1ae857a1b0cca4550c7cd7e($fileIdentifier, $file);
}
return $loader;
}
}
function composerRequire381ef710b1ae857a1b0cca4550c7cd7e($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
}
}

View File

@@ -0,0 +1,188 @@
<?php
// autoload_static.php @generated by Composer
namespace Composer\Autoload;
class ComposerStaticInit381ef710b1ae857a1b0cca4550c7cd7e
{
public static $files = array (
//'7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php',
//'c964ee0ededf28c96ebd9db5099ef910' => __DIR__ . '/..' . '/guzzlehttp/promises/src/functions_include.php',
//'a0edc8309cc5e1d60e3047b5df6b7052' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/functions_include.php',
//'37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php',
//'decc78cc4436b1292c6c0d151b19445c' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/bootstrap.php',
//'3919eeb97e98d4648304477f8ef734ba' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/Random.php',
'7b11c4dc42b3b3023073cb14e519684c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php',
'c964ee0ededf28c96ebd9db5099ef911' => __DIR__ . '/..' . '/guzzlehttp/promises/src/functions_include.php',
'a0edc8309cc5e1d60e3047b5df6b7057' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/functions_include.php',
'37a3dc5111fe8f707ab4c132ef1dbc63' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php',
'decc78cc4436b1292c6c0d151b19446c' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/bootstrap.php',
'3919eeb97e98d4648304477f8ef735ba' => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib/Crypt/Random.php',
);
public static $prefixLengthsPsr4 = array (
'S' =>
array (
'Symfony\\Component\\EventDispatcher\\' => 34,
),
/*'P' =>
array (
'Psr\\Log\\' => 8,
'Psr\\Http\\Message\\' => 17,
'Psr\\Cache\\' => 10,
),*/
/*'M' =>
array (
'Monolog\\' => 8,
),*/
'W' =>
array (
'WPvividGuzzleHttp\\Psr7\\' => 23,
'WPvividGuzzleHttp\\Promise\\' => 26,
'WPvividGuzzleHttp\\' => 18,
'WPvividGoogle\\Auth\\' => 19,
'WPvividPsr\\Log\\' => 15,
'WPvividPsr\\Http\\Message\\' => 24,
'WPvividPsr\\Cache\\' => 17,
'WPvividMonolog\\' => 15,
),
'F' =>
array (
'Firebase\\JWT\\' => 13,
),
);
public static $prefixDirsPsr4 = array (
'Symfony\\Component\\EventDispatcher\\' =>
array (
0 => __DIR__ . '/..' . '/symfony/event-dispatcher',
),
'WPvividPsr\\Log\\' =>
array (
0 => __DIR__ . '/..' . '/psr/log/Psr/Log',
),
'WPvividPsr\\Http\\Message\\' =>
array (
0 => __DIR__ . '/..' . '/psr/http-message/src',
),
'WPvividPsr\\Cache\\' =>
array (
0 => __DIR__ . '/..' . '/psr/cache/src',
),
'WPvividMonolog\\' =>
array (
0 => __DIR__ . '/..' . '/monolog/monolog/src/Monolog',
),
'WPvividGuzzleHttp\\Psr7\\' =>
array (
0 => __DIR__ . '/..' . '/guzzlehttp/psr7/src',
),
'WPvividGuzzleHttp\\Promise\\' =>
array (
0 => __DIR__ . '/..' . '/guzzlehttp/promises/src',
),
'WPvividGuzzleHttp\\' =>
array (
0 => __DIR__ . '/..' . '/guzzlehttp/guzzle/src',
),
'WPvividGoogle\\Auth\\' =>
array (
0 => __DIR__ . '/..' . '/google/auth/src',
),
'Firebase\\JWT\\' =>
array (
0 => __DIR__ . '/..' . '/firebase/php-jwt/src',
),
);
public static $prefixesPsr0 = array (
'S' =>
array (
'System' =>
array (
0 => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib',
),
),
'N' =>
array (
'Net' =>
array (
0 => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib',
),
),
'M' =>
array (
'Math' =>
array (
0 => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib',
),
),
'G' =>
array (
'Guzzle\\Tests' =>
array (
0 => __DIR__ . '/..' . '/guzzle/guzzle/tests',
),
'Guzzle' =>
array (
0 => __DIR__ . '/..' . '/guzzle/guzzle/src',
),
'Google_Service_' =>
array (
0 => __DIR__ . '/..' . '/google/apiclient-services/src',
),
'Google_' =>
array (
0 => __DIR__ . '/../..' . '/includes/lib/google-api-php-client/src',
),
),
'W' =>
array (
'WPvivid_Google_' =>
array (
0 => __DIR__ . '/../..' . '/includes/lib2/google-api-php-client/src',
),
),
'F' =>
array (
'File' =>
array (
0 => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib',
),
),
'C' =>
array (
'Crypt' =>
array (
0 => __DIR__ . '/..' . '/phpseclib/phpseclib/phpseclib',
),
),
'A' =>
array (
'Aws' =>
array (
0 => __DIR__ . '/../..' . '/includes/lib/aws-sdk-php-2.8.31/src',
),
),
);
public static $classMap = array (
'Google_Service_Exception' => __DIR__ . '/../..' . '/includes/lib/google-api-php-client/src/Google/Service/Exception.php',
'Google_Service_Resource' => __DIR__ . '/../..' . '/includes/lib/google-api-php-client/src/Google/Service/Resource.php',
'WPvivid_Google_Service_Exception' => __DIR__ . '/../..' . '/includes/lib2/google-api-php-client/src/WPvivid/Google/Service/Exception.php',
'WPvivid_Google_Service_Resource' => __DIR__ . '/../..' . '/includes/lib2/google-api-php-client/src/WPvivid/Google/Service/Resource.php',
);
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
$loader->prefixLengthsPsr4 = ComposerStaticInit381ef710b1ae857a1b0cca4550c7cd7e::$prefixLengthsPsr4;
$loader->prefixDirsPsr4 = ComposerStaticInit381ef710b1ae857a1b0cca4550c7cd7e::$prefixDirsPsr4;
$loader->prefixesPsr0 = ComposerStaticInit381ef710b1ae857a1b0cca4550c7cd7e::$prefixesPsr0;
$loader->classMap = ComposerStaticInit381ef710b1ae857a1b0cca4550c7cd7e::$classMap;
}, null, ClassLoader::class);
}
}

View File

@@ -0,0 +1,10 @@
<?php
// include_paths.php @generated by Composer
$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);
return array(
$vendorDir . '/phpseclib/phpseclib/phpseclib',
);

View File

@@ -0,0 +1,943 @@
[
{
"name": "firebase/php-jwt",
"version": "v5.0.0",
"version_normalized": "5.0.0.0",
"source": {
"type": "git",
"url": "https://github.com/firebase/php-jwt.git",
"reference": "9984a4d3a32ae7673d6971ea00bae9d0a1abba0e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/firebase/php-jwt/zipball/9984a4d3a32ae7673d6971ea00bae9d0a1abba0e",
"reference": "9984a4d3a32ae7673d6971ea00bae9d0a1abba0e",
"shasum": "",
"mirrors": [
{
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": " 4.8.35"
},
"time": "2017-06-27T22:17:23+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-4": {
"Firebase\\JWT\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"BSD-3-Clause"
],
"authors": [
{
"name": "Neuman Vong",
"email": "neuman+pear@twilio.com",
"role": "Developer"
},
{
"name": "Anant Narayanan",
"email": "anant@php.net",
"role": "Developer"
}
],
"description": "A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.",
"homepage": "https://github.com/firebase/php-jwt"
},
{
"name": "google/apiclient-services",
"version": "v0.13",
"version_normalized": "0.13.0.0",
"source": {
"type": "git",
"url": "https://github.com/googleapis/google-api-php-client-services.git",
"reference": "0805897f3435f9eea73ce21da9d55f51c69c1171"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/googleapis/google-api-php-client-services/zipball/0805897f3435f9eea73ce21da9d55f51c69c1171",
"reference": "0805897f3435f9eea73ce21da9d55f51c69c1171",
"shasum": "",
"mirrors": [
{
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.4"
},
"require-dev": {
"phpunit/phpunit": "~4.8"
},
"time": "2017-07-07T16:01:27+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-0": {
"Google_Service_": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache-2.0"
],
"description": "Client library for Google APIs",
"homepage": "http://developers.google.com/api-client-library/php",
"keywords": [
"google"
]
},
{
"name": "google/auth",
"version": "v1.4.0",
"version_normalized": "1.4.0.0",
"source": {
"type": "git",
"url": "https://github.com/googleapis/google-auth-library-php.git",
"reference": "196237248e636a3554a7d9e4dfddeb97f450ab5c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/googleapis/google-auth-library-php/zipball/196237248e636a3554a7d9e4dfddeb97f450ab5c",
"reference": "196237248e636a3554a7d9e4dfddeb97f450ab5c",
"shasum": "",
"mirrors": [
{
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"firebase/php-jwt": "~2.0|~3.0|~4.0|~5.0",
"guzzlehttp/guzzle": "~5.3.1|~6.0",
"guzzlehttp/psr7": "^1.2",
"php": ">=5.4",
"psr/cache": "^1.0",
"psr/http-message": "^1.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^1.11",
"guzzlehttp/promises": "0.1.1|^1.3",
"phpunit/phpunit": "^4.8.36|^5.7",
"sebastian/comparator": ">=1.2.3"
},
"time": "2018-09-17T20:29:21+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-4": {
"WPvividGoogle\\Auth\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"Apache-2.0"
],
"description": "Google Auth Library for PHP",
"homepage": "http://github.com/google/google-auth-library-php",
"keywords": [
"Authentication",
"google",
"oauth2"
]
},
{
"name": "guzzle/guzzle",
"version": "v3.9.3",
"version_normalized": "3.9.3.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/guzzle3.git",
"reference": "0645b70d953bc1c067bbc8d5bc53194706b628d9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/guzzle3/zipball/0645b70d953bc1c067bbc8d5bc53194706b628d9",
"reference": "0645b70d953bc1c067bbc8d5bc53194706b628d9",
"shasum": "",
"mirrors": [
{
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"ext-curl": "*",
"php": ">=5.3.3",
"symfony/event-dispatcher": "~2.1"
},
"replace": {
"guzzle/batch": "self.version",
"guzzle/cache": "self.version",
"guzzle/common": "self.version",
"guzzle/http": "self.version",
"guzzle/inflection": "self.version",
"guzzle/iterator": "self.version",
"guzzle/log": "self.version",
"guzzle/parser": "self.version",
"guzzle/plugin": "self.version",
"guzzle/plugin-async": "self.version",
"guzzle/plugin-backoff": "self.version",
"guzzle/plugin-cache": "self.version",
"guzzle/plugin-cookie": "self.version",
"guzzle/plugin-curlauth": "self.version",
"guzzle/plugin-error-response": "self.version",
"guzzle/plugin-history": "self.version",
"guzzle/plugin-log": "self.version",
"guzzle/plugin-md5": "self.version",
"guzzle/plugin-mock": "self.version",
"guzzle/plugin-oauth": "self.version",
"guzzle/service": "self.version",
"guzzle/stream": "self.version"
},
"require-dev": {
"doctrine/cache": "~1.3",
"monolog/monolog": "~1.0",
"phpunit/phpunit": "3.7.*",
"psr/log": "~1.0",
"symfony/class-loader": "~2.1",
"zendframework/zend-cache": "2.*,<2.3",
"zendframework/zend-log": "2.*,<2.3"
},
"suggest": {
"guzzlehttp/guzzle": "Guzzle 5 has moved to a new package name. The package you have installed, Guzzle 3, is deprecated."
},
"time": "2015-03-18T18:23:50+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.9-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-0": {
"Guzzle": "src/",
"Guzzle\\Tests": "tests/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
},
{
"name": "Guzzle Community",
"homepage": "https://github.com/guzzle/guzzle/contributors"
}
],
"description": "PHP HTTP client. This library is deprecated in favor of https://packagist.org/packages/guzzlehttp/guzzle",
"homepage": "http://guzzlephp.org/",
"keywords": [
"client",
"curl",
"framework",
"http",
"http client",
"rest",
"web service"
],
"abandoned": "guzzlehttp/guzzle"
},
{
"name": "guzzlehttp/guzzle",
"version": "6.3.3",
"version_normalized": "6.3.3.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/guzzle.git",
"reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/guzzle/zipball/407b0cb880ace85c9b63c5f9551db498cb2d50ba",
"reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba",
"shasum": "",
"mirrors": [
{
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"guzzlehttp/promises": "^1.0",
"guzzlehttp/psr7": "^1.4",
"php": ">=5.5"
},
"require-dev": {
"ext-curl": "*",
"phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0",
"psr/log": "^1.0"
},
"suggest": {
"psr/log": "Required for using the Log middleware"
},
"time": "2018-04-22T15:46:56+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "6.3-dev"
}
},
"installation-source": "dist",
"autoload": {
"files": [
"src/functions_include.php"
],
"psr-4": {
"WPvividGuzzleHttp\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
}
],
"description": "Guzzle is a PHP HTTP client library",
"homepage": "http://guzzlephp.org/",
"keywords": [
"client",
"curl",
"framework",
"http",
"http client",
"rest",
"web service"
]
},
{
"name": "guzzlehttp/promises",
"version": "v1.3.1",
"version_normalized": "1.3.1.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/promises.git",
"reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/promises/zipball/a59da6cf61d80060647ff4d3eb2c03a2bc694646",
"reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646",
"shasum": "",
"mirrors": [
{
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.5.0"
},
"require-dev": {
"phpunit/phpunit": "^4.0"
},
"time": "2016-12-20T10:07:11+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.4-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"WPvividGuzzleHttp\\Promise\\": "src/"
},
"files": [
"src/functions_include.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
}
],
"description": "Guzzle promises library",
"keywords": [
"promise"
]
},
{
"name": "guzzlehttp/psr7",
"version": "1.5.2",
"version_normalized": "1.5.2.0",
"source": {
"type": "git",
"url": "https://github.com/guzzle/psr7.git",
"reference": "9f83dded91781a01c63574e387eaa769be769115"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/guzzle/psr7/zipball/9f83dded91781a01c63574e387eaa769be769115",
"reference": "9f83dded91781a01c63574e387eaa769be769115",
"shasum": "",
"mirrors": [
{
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.4.0",
"psr/http-message": "~1.0",
"ralouphie/getallheaders": "^2.0.5"
},
"provide": {
"psr/http-message-implementation": "1.0"
},
"require-dev": {
"phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.8"
},
"time": "2018-12-04T20:46:45+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.5-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"WPvividGuzzleHttp\\Psr7\\": "src/"
},
"files": [
"src/functions_include.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Michael Dowling",
"email": "mtdowling@gmail.com",
"homepage": "https://github.com/mtdowling"
},
{
"name": "Tobias Schultze",
"homepage": "https://github.com/Tobion"
}
],
"description": "PSR-7 message implementation that also provides common utility methods",
"keywords": [
"http",
"message",
"psr-7",
"request",
"response",
"stream",
"uri",
"url"
]
},
{
"name": "monolog/monolog",
"version": "1.24.0",
"version_normalized": "1.24.0.0",
"source": {
"type": "git",
"url": "https://github.com/Seldaek/monolog.git",
"reference": "bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Seldaek/monolog/zipball/bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266",
"reference": "bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266",
"shasum": "",
"mirrors": [
{
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.0",
"psr/log": "~1.0"
},
"provide": {
"psr/log-implementation": "1.0.0"
},
"require-dev": {
"aws/aws-sdk-php": "^2.4.9 || ^3.0",
"doctrine/couchdb": "~1.0@dev",
"graylog2/gelf-php": "~1.0",
"jakub-onderka/php-parallel-lint": "0.9",
"php-amqplib/php-amqplib": "~2.4",
"php-console/php-console": "^3.1.3",
"phpunit/phpunit": "~4.5",
"phpunit/phpunit-mock-objects": "2.3.0",
"ruflin/elastica": ">=0.90 <3.0",
"sentry/sentry": "^0.13",
"swiftmailer/swiftmailer": "^5.3|^6.0"
},
"suggest": {
"aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB",
"doctrine/couchdb": "Allow sending log messages to a CouchDB server",
"ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)",
"ext-mongo": "Allow sending log messages to a MongoDB server",
"graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server",
"mongodb/mongodb": "Allow sending log messages to a MongoDB server via PHP Driver",
"php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib",
"php-console/php-console": "Allow sending log messages to Google Chrome",
"rollbar/rollbar": "Allow sending log messages to Rollbar",
"ruflin/elastica": "Allow sending log messages to an Elastic Search server",
"sentry/sentry": "Allow sending log messages to a Sentry server"
},
"time": "2018-11-05T09:00:11+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"Monolog\\": "src/Monolog"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "http://seld.be"
}
],
"description": "Sends your logs to files, sockets, inboxes, databases and various web services",
"homepage": "http://github.com/Seldaek/monolog",
"keywords": [
"log",
"logging",
"psr-3"
]
},
{
"name": "phpseclib/phpseclib",
"version": "1.0.14",
"version_normalized": "1.0.14.0",
"source": {
"type": "git",
"url": "https://github.com/phpseclib/phpseclib.git",
"reference": "7432a6959afe98b9e93153d0034b0f62ad890d31"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/7432a6959afe98b9e93153d0034b0f62ad890d31",
"reference": "7432a6959afe98b9e93153d0034b0f62ad890d31",
"shasum": "",
"mirrors": [
{
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.0.0"
},
"require-dev": {
"phing/phing": "~2.7",
"phpunit/phpunit": "^4.8.35|^5.7|^6.0",
"sami/sami": "~2.0",
"squizlabs/php_codesniffer": "~2.0"
},
"suggest": {
"ext-gmp": "Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.",
"ext-mcrypt": "Install the Mcrypt extension in order to speed up a wide variety of cryptographic operations.",
"pear-pear/PHP_Compat": "Install PHP_Compat to get phpseclib working on PHP < 5.0.0."
},
"time": "2019-01-27T19:35:10+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"psr-0": {
"Crypt": "phpseclib/",
"File": "phpseclib/",
"Math": "phpseclib/",
"Net": "phpseclib/",
"System": "phpseclib/"
},
"files": [
"phpseclib/bootstrap.php",
"phpseclib/Crypt/Random.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"include-path": [
"phpseclib/"
],
"license": [
"MIT"
],
"authors": [
{
"name": "Jim Wigginton",
"email": "terrafrost@php.net",
"role": "Lead Developer"
},
{
"name": "Patrick Monnerat",
"email": "pm@datasphere.ch",
"role": "Developer"
},
{
"name": "Andreas Fischer",
"email": "bantu@phpbb.com",
"role": "Developer"
},
{
"name": "Hans-Jürgen Petrich",
"email": "petrich@tronic-media.com",
"role": "Developer"
},
{
"name": "Graham Campbell",
"email": "graham@alt-three.com",
"role": "Developer"
}
],
"description": "PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.",
"homepage": "http://phpseclib.sourceforge.net",
"keywords": [
"BigInteger",
"aes",
"asn.1",
"asn1",
"blowfish",
"crypto",
"cryptography",
"encryption",
"rsa",
"security",
"sftp",
"signature",
"signing",
"ssh",
"twofish",
"x.509",
"x509"
]
},
{
"name": "psr/cache",
"version": "1.0.1",
"version_normalized": "1.0.1.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/cache.git",
"reference": "d11b50ad223250cf17b86e38383413f5a6764bf8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/cache/zipball/d11b50ad223250cf17b86e38383413f5a6764bf8",
"reference": "d11b50ad223250cf17b86e38383413f5a6764bf8",
"shasum": "",
"mirrors": [
{
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.0"
},
"time": "2016-08-06T20:24:11+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"WPvividPsr\\Cache\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interface for caching libraries",
"keywords": [
"cache",
"psr",
"psr-6"
]
},
{
"name": "psr/http-message",
"version": "1.0.1",
"version_normalized": "1.0.1.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-message.git",
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363",
"reference": "f6561bf28d520154e4b0ec72be95418abe6d9363",
"shasum": "",
"mirrors": [
{
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.0"
},
"time": "2016-08-06T14:39:51+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"WPvividPsr\\Http\\Message\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interface for HTTP messages",
"homepage": "https://github.com/php-fig/http-message",
"keywords": [
"http",
"http-message",
"psr",
"psr-7",
"request",
"response"
]
},
{
"name": "psr/log",
"version": "1.1.0",
"version_normalized": "1.1.0.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/log.git",
"reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/log/zipball/6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd",
"reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd",
"shasum": "",
"mirrors": [
{
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.0"
},
"time": "2018-11-20T15:27:04+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"WPvividPsr\\Log\\": "Psr/Log/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
}
],
"description": "Common interface for logging libraries",
"homepage": "https://github.com/php-fig/log",
"keywords": [
"log",
"psr",
"psr-3"
]
},
{
"name": "ralouphie/getallheaders",
"version": "2.0.5",
"version_normalized": "2.0.5.0",
"source": {
"type": "git",
"url": "https://github.com/ralouphie/getallheaders.git",
"reference": "5601c8a83fbba7ef674a7369456d12f1e0d0eafa"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/5601c8a83fbba7ef674a7369456d12f1e0d0eafa",
"reference": "5601c8a83fbba7ef674a7369456d12f1e0d0eafa",
"shasum": "",
"mirrors": [
{
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3"
},
"require-dev": {
"phpunit/phpunit": "~3.7.0",
"satooshi/php-coveralls": ">=1.0"
},
"time": "2016-02-11T07:05:27+00:00",
"type": "library",
"installation-source": "dist",
"autoload": {
"files": [
"src/getallheaders.php"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Ralph Khattar",
"email": "ralph.khattar@gmail.com"
}
],
"description": "A polyfill for getallheaders."
},
{
"name": "symfony/event-dispatcher",
"version": "v2.8.49",
"version_normalized": "2.8.49.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher.git",
"reference": "a77e974a5fecb4398833b0709210e3d5e334ffb0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/a77e974a5fecb4398833b0709210e3d5e334ffb0",
"reference": "a77e974a5fecb4398833b0709210e3d5e334ffb0",
"shasum": "",
"mirrors": [
{
"url": "https://dl.laravel-china.org/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=5.3.9"
},
"require-dev": {
"psr/log": "~1.0",
"symfony/config": "^2.0.5|~3.0.0",
"symfony/dependency-injection": "~2.6|~3.0.0",
"symfony/expression-language": "~2.6|~3.0.0",
"symfony/stopwatch": "~2.3|~3.0.0"
},
"suggest": {
"symfony/dependency-injection": "",
"symfony/http-kernel": ""
},
"time": "2018-11-21T14:20:20+00:00",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.8-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-4": {
"Symfony\\Component\\EventDispatcher\\": ""
},
"exclude-from-classmap": [
"/Tests/"
]
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony EventDispatcher Component",
"homepage": "https://symfony.com"
}
]

View File

@@ -0,0 +1,30 @@
Copyright (c) 2011, Neuman Vong
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Neuman Vong nor the names of other
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -0,0 +1,200 @@
[![Build Status](https://travis-ci.org/firebase/php-jwt.png?branch=master)](https://travis-ci.org/firebase/php-jwt)
[![Latest Stable Version](https://poser.pugx.org/firebase/php-jwt/v/stable)](https://packagist.org/packages/firebase/php-jwt)
[![Total Downloads](https://poser.pugx.org/firebase/php-jwt/downloads)](https://packagist.org/packages/firebase/php-jwt)
[![License](https://poser.pugx.org/firebase/php-jwt/license)](https://packagist.org/packages/firebase/php-jwt)
PHP-JWT
=======
A simple library to encode and decode JSON Web Tokens (JWT) in PHP, conforming to [RFC 7519](https://tools.ietf.org/html/rfc7519).
Installation
------------
Use composer to manage your dependencies and download PHP-JWT:
```bash
composer require firebase/php-jwt
```
Example
-------
```php
<?php
use \Firebase\JWT\JWT;
$key = "example_key";
$token = array(
"iss" => "http://example.org",
"aud" => "http://example.com",
"iat" => 1356999524,
"nbf" => 1357000000
);
/**
* IMPORTANT:
* You must specify supported algorithms for your application. See
* https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40
* for a list of spec-compliant algorithms.
*/
$jwt = JWT::encode($token, $key);
$decoded = JWT::decode($jwt, $key, array('HS256'));
print_r($decoded);
/*
NOTE: This will now be an object instead of an associative array. To get
an associative array, you will need to cast it as such:
*/
$decoded_array = (array) $decoded;
/**
* You can add a leeway to account for when there is a clock skew times between
* the signing and verifying servers. It is recommended that this leeway should
* not be bigger than a few minutes.
*
* Source: http://self-issued.info/docs/draft-ietf-oauth-json-web-token.html#nbfDef
*/
JWT::$leeway = 60; // $leeway in seconds
$decoded = JWT::decode($jwt, $key, array('HS256'));
?>
```
Example with RS256 (openssl)
----------------------------
```php
<?php
use \Firebase\JWT\JWT;
$privateKey = <<<EOD
-----BEGIN RSA PRIVATE KEY-----
MIICXAIBAAKBgQC8kGa1pSjbSYZVebtTRBLxBz5H4i2p/llLCrEeQhta5kaQu/Rn
vuER4W8oDH3+3iuIYW4VQAzyqFpwuzjkDI+17t5t0tyazyZ8JXw+KgXTxldMPEL9
5+qVhgXvwtihXC1c5oGbRlEDvDF6Sa53rcFVsYJ4ehde/zUxo6UvS7UrBQIDAQAB
AoGAb/MXV46XxCFRxNuB8LyAtmLDgi/xRnTAlMHjSACddwkyKem8//8eZtw9fzxz
bWZ/1/doQOuHBGYZU8aDzzj59FZ78dyzNFoF91hbvZKkg+6wGyd/LrGVEB+Xre0J
Nil0GReM2AHDNZUYRv+HYJPIOrB0CRczLQsgFJ8K6aAD6F0CQQDzbpjYdx10qgK1
cP59UHiHjPZYC0loEsk7s+hUmT3QHerAQJMZWC11Qrn2N+ybwwNblDKv+s5qgMQ5
5tNoQ9IfAkEAxkyffU6ythpg/H0Ixe1I2rd0GbF05biIzO/i77Det3n4YsJVlDck
ZkcvY3SK2iRIL4c9yY6hlIhs+K9wXTtGWwJBAO9Dskl48mO7woPR9uD22jDpNSwe
k90OMepTjzSvlhjbfuPN1IdhqvSJTDychRwn1kIJ7LQZgQ8fVz9OCFZ/6qMCQGOb
qaGwHmUK6xzpUbbacnYrIM6nLSkXgOAwv7XXCojvY614ILTK3iXiLBOxPu5Eu13k
eUz9sHyD6vkgZzjtxXECQAkp4Xerf5TGfQXGXhxIX52yH+N2LtujCdkQZjXAsGdm
B2zNzvrlgRmgBrklMTrMYgm1NPcW+bRLGcwgW2PTvNM=
-----END RSA PRIVATE KEY-----
EOD;
$publicKey = <<<EOD
-----BEGIN PUBLIC KEY-----
MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC8kGa1pSjbSYZVebtTRBLxBz5H
4i2p/llLCrEeQhta5kaQu/RnvuER4W8oDH3+3iuIYW4VQAzyqFpwuzjkDI+17t5t
0tyazyZ8JXw+KgXTxldMPEL95+qVhgXvwtihXC1c5oGbRlEDvDF6Sa53rcFVsYJ4
ehde/zUxo6UvS7UrBQIDAQAB
-----END PUBLIC KEY-----
EOD;
$token = array(
"iss" => "example.org",
"aud" => "example.com",
"iat" => 1356999524,
"nbf" => 1357000000
);
$jwt = JWT::encode($token, $privateKey, 'RS256');
echo "Encode:\n" . print_r($jwt, true) . "\n";
$decoded = JWT::decode($jwt, $publicKey, array('RS256'));
/*
NOTE: This will now be an object instead of an associative array. To get
an associative array, you will need to cast it as such:
*/
$decoded_array = (array) $decoded;
echo "Decode:\n" . print_r($decoded_array, true) . "\n";
?>
```
Changelog
---------
#### 5.0.0 / 2017-06-26
- Support RS384 and RS512.
See [#117](https://github.com/firebase/php-jwt/pull/117). Thanks [@joostfaassen](https://github.com/joostfaassen)!
- Add an example for RS256 openssl.
See [#125](https://github.com/firebase/php-jwt/pull/125). Thanks [@akeeman](https://github.com/akeeman)!
- Detect invalid Base64 encoding in signature.
See [#162](https://github.com/firebase/php-jwt/pull/162). Thanks [@psignoret](https://github.com/psignoret)!
- Update `JWT::verify` to handle OpenSSL errors.
See [#159](https://github.com/firebase/php-jwt/pull/159). Thanks [@bshaffer](https://github.com/bshaffer)!
- Add `array` type hinting to `decode` method
See [#101](https://github.com/firebase/php-jwt/pull/101). Thanks [@hywak](https://github.com/hywak)!
- Add all JSON error types.
See [#110](https://github.com/firebase/php-jwt/pull/110). Thanks [@gbalduzzi](https://github.com/gbalduzzi)!
- Bugfix 'kid' not in given key list.
See [#129](https://github.com/firebase/php-jwt/pull/129). Thanks [@stampycode](https://github.com/stampycode)!
- Miscellaneous cleanup, documentation and test fixes.
See [#107](https://github.com/firebase/php-jwt/pull/107), [#115](https://github.com/firebase/php-jwt/pull/115),
[#160](https://github.com/firebase/php-jwt/pull/160), [#161](https://github.com/firebase/php-jwt/pull/161), and
[#165](https://github.com/firebase/php-jwt/pull/165). Thanks [@akeeman](https://github.com/akeeman),
[@chinedufn](https://github.com/chinedufn), and [@bshaffer](https://github.com/bshaffer)!
#### 4.0.0 / 2016-07-17
- Add support for late static binding. See [#88](https://github.com/firebase/php-jwt/pull/88) for details. Thanks to [@chappy84](https://github.com/chappy84)!
- Use static `$timestamp` instead of `time()` to improve unit testing. See [#93](https://github.com/firebase/php-jwt/pull/93) for details. Thanks to [@josephmcdermott](https://github.com/josephmcdermott)!
- Fixes to exceptions classes. See [#81](https://github.com/firebase/php-jwt/pull/81) for details. Thanks to [@Maks3w](https://github.com/Maks3w)!
- Fixes to PHPDoc. See [#76](https://github.com/firebase/php-jwt/pull/76) for details. Thanks to [@akeeman](https://github.com/akeeman)!
#### 3.0.0 / 2015-07-22
- Minimum PHP version updated from `5.2.0` to `5.3.0`.
- Add `\Firebase\JWT` namespace. See
[#59](https://github.com/firebase/php-jwt/pull/59) for details. Thanks to
[@Dashron](https://github.com/Dashron)!
- Require a non-empty key to decode and verify a JWT. See
[#60](https://github.com/firebase/php-jwt/pull/60) for details. Thanks to
[@sjones608](https://github.com/sjones608)!
- Cleaner documentation blocks in the code. See
[#62](https://github.com/firebase/php-jwt/pull/62) for details. Thanks to
[@johanderuijter](https://github.com/johanderuijter)!
#### 2.2.0 / 2015-06-22
- Add support for adding custom, optional JWT headers to `JWT::encode()`. See
[#53](https://github.com/firebase/php-jwt/pull/53/files) for details. Thanks to
[@mcocaro](https://github.com/mcocaro)!
#### 2.1.0 / 2015-05-20
- Add support for adding a leeway to `JWT:decode()` that accounts for clock skew
between signing and verifying entities. Thanks to [@lcabral](https://github.com/lcabral)!
- Add support for passing an object implementing the `ArrayAccess` interface for
`$keys` argument in `JWT::decode()`. Thanks to [@aztech-dev](https://github.com/aztech-dev)!
#### 2.0.0 / 2015-04-01
- **Note**: It is strongly recommended that you update to > v2.0.0 to address
known security vulnerabilities in prior versions when both symmetric and
asymmetric keys are used together.
- Update signature for `JWT::decode(...)` to require an array of supported
algorithms to use when verifying token signatures.
Tests
-----
Run the tests using phpunit:
```bash
$ pear install PHPUnit
$ phpunit --configuration phpunit.xml.dist
PHPUnit 3.7.10 by Sebastian Bergmann.
.....
Time: 0 seconds, Memory: 2.50Mb
OK (5 tests, 5 assertions)
```
New Lines in private keys
-----
If your private key contains `\n` characters, be sure to wrap it in double quotes `""`
and not single quotes `''` in order to properly interpret the escaped characters.
License
-------
[3-Clause BSD](http://opensource.org/licenses/BSD-3-Clause).

View File

@@ -0,0 +1,29 @@
{
"name": "firebase/php-jwt",
"description": "A simple library to encode and decode JSON Web Tokens (JWT) in PHP. Should conform to the current spec.",
"homepage": "https://github.com/firebase/php-jwt",
"authors": [
{
"name": "Neuman Vong",
"email": "neuman+pear@twilio.com",
"role": "Developer"
},
{
"name": "Anant Narayanan",
"email": "anant@php.net",
"role": "Developer"
}
],
"license": "BSD-3-Clause",
"require": {
"php": ">=5.3.0"
},
"autoload": {
"psr-4": {
"Firebase\\JWT\\": "src"
}
},
"require-dev": {
"phpunit/phpunit": " 4.8.35"
}
}

View File

@@ -0,0 +1,7 @@
<?php
namespace Firebase\JWT;
class BeforeValidException extends \UnexpectedValueException
{
}

View File

@@ -0,0 +1,7 @@
<?php
namespace Firebase\JWT;
class ExpiredException extends \UnexpectedValueException
{
}

View File

@@ -0,0 +1,379 @@
<?php
namespace Firebase\JWT;
use \DomainException;
use \InvalidArgumentException;
use \UnexpectedValueException;
use \DateTime;
/**
* JSON Web Token implementation, based on this spec:
* https://tools.ietf.org/html/rfc7519
*
* PHP version 5
*
* @category Authentication
* @package Authentication_JWT
* @author Neuman Vong <neuman@twilio.com>
* @author Anant Narayanan <anant@php.net>
* @license http://opensource.org/licenses/BSD-3-Clause 3-clause BSD
* @link https://github.com/firebase/php-jwt
*/
class JWT
{
/**
* When checking nbf, iat or expiration times,
* we want to provide some extra leeway time to
* account for clock skew.
*/
public static $leeway = 0;
/**
* Allow the current timestamp to be specified.
* Useful for fixing a value within unit testing.
*
* Will default to PHP time() value if null.
*/
public static $timestamp = null;
public static $supported_algs = array(
'HS256' => array('hash_hmac', 'SHA256'),
'HS512' => array('hash_hmac', 'SHA512'),
'HS384' => array('hash_hmac', 'SHA384'),
'RS256' => array('openssl', 'SHA256'),
'RS384' => array('openssl', 'SHA384'),
'RS512' => array('openssl', 'SHA512'),
);
/**
* Decodes a JWT string into a PHP object.
*
* @param string $jwt The JWT
* @param string|array $key The key, or map of keys.
* If the algorithm used is asymmetric, this is the public key
* @param array $allowed_algs List of supported verification algorithms
* Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256'
*
* @return object The JWT's payload as a PHP object
*
* @throws UnexpectedValueException Provided JWT was invalid
* @throws SignatureInvalidException Provided JWT was invalid because the signature verification failed
* @throws BeforeValidException Provided JWT is trying to be used before it's eligible as defined by 'nbf'
* @throws BeforeValidException Provided JWT is trying to be used before it's been created as defined by 'iat'
* @throws ExpiredException Provided JWT has since expired, as defined by the 'exp' claim
*
* @uses jsonDecode
* @uses urlsafeB64Decode
*/
public static function decode($jwt, $key, array $allowed_algs = array())
{
$timestamp = is_null(static::$timestamp) ? time() : static::$timestamp;
if (empty($key)) {
throw new InvalidArgumentException('Key may not be empty');
}
$tks = explode('.', $jwt);
if (count($tks) != 3) {
throw new UnexpectedValueException('Wrong number of segments');
}
list($headb64, $bodyb64, $cryptob64) = $tks;
if (null === ($header = static::jsonDecode(static::urlsafeB64Decode($headb64)))) {
throw new UnexpectedValueException('Invalid header encoding');
}
if (null === $payload = static::jsonDecode(static::urlsafeB64Decode($bodyb64))) {
throw new UnexpectedValueException('Invalid claims encoding');
}
if (false === ($sig = static::urlsafeB64Decode($cryptob64))) {
throw new UnexpectedValueException('Invalid signature encoding');
}
if (empty($header->alg)) {
throw new UnexpectedValueException('Empty algorithm');
}
if (empty(static::$supported_algs[$header->alg])) {
throw new UnexpectedValueException('Algorithm not supported');
}
if (!in_array($header->alg, $allowed_algs)) {
throw new UnexpectedValueException('Algorithm not allowed');
}
if (is_array($key) || $key instanceof \ArrayAccess) {
if (isset($header->kid)) {
if (!isset($key[$header->kid])) {
throw new UnexpectedValueException('"kid" invalid, unable to lookup correct key');
}
$key = $key[$header->kid];
} else {
throw new UnexpectedValueException('"kid" empty, unable to lookup correct key');
}
}
// Check the signature
if (!static::verify("$headb64.$bodyb64", $sig, $key, $header->alg)) {
throw new SignatureInvalidException('Signature verification failed');
}
// Check if the nbf if it is defined. This is the time that the
// token can actually be used. If it's not yet that time, abort.
if (isset($payload->nbf) && $payload->nbf > ($timestamp + static::$leeway)) {
throw new BeforeValidException(
'Cannot handle token prior to ' . date(DateTime::ISO8601, $payload->nbf)
);
}
// Check that this token has been created before 'now'. This prevents
// using tokens that have been created for later use (and haven't
// correctly used the nbf claim).
if (isset($payload->iat) && $payload->iat > ($timestamp + static::$leeway)) {
throw new BeforeValidException(
'Cannot handle token prior to ' . date(DateTime::ISO8601, $payload->iat)
);
}
// Check if this token has expired.
if (isset($payload->exp) && ($timestamp - static::$leeway) >= $payload->exp) {
throw new ExpiredException('Expired token');
}
return $payload;
}
/**
* Converts and signs a PHP object or array into a JWT string.
*
* @param object|array $payload PHP object or array
* @param string $key The secret key.
* If the algorithm used is asymmetric, this is the private key
* @param string $alg The signing algorithm.
* Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256'
* @param mixed $keyId
* @param array $head An array with header elements to attach
*
* @return string A signed JWT
*
* @uses jsonEncode
* @uses urlsafeB64Encode
*/
public static function encode($payload, $key, $alg = 'HS256', $keyId = null, $head = null)
{
$header = array('typ' => 'JWT', 'alg' => $alg);
if ($keyId !== null) {
$header['kid'] = $keyId;
}
if ( isset($head) && is_array($head) ) {
$header = array_merge($head, $header);
}
$segments = array();
$segments[] = static::urlsafeB64Encode(static::jsonEncode($header));
$segments[] = static::urlsafeB64Encode(static::jsonEncode($payload));
$signing_input = implode('.', $segments);
$signature = static::sign($signing_input, $key, $alg);
$segments[] = static::urlsafeB64Encode($signature);
return implode('.', $segments);
}
/**
* Sign a string with a given key and algorithm.
*
* @param string $msg The message to sign
* @param string|resource $key The secret key
* @param string $alg The signing algorithm.
* Supported algorithms are 'HS256', 'HS384', 'HS512' and 'RS256'
*
* @return string An encrypted message
*
* @throws DomainException Unsupported algorithm was specified
*/
public static function sign($msg, $key, $alg = 'HS256')
{
if (empty(static::$supported_algs[$alg])) {
throw new DomainException('Algorithm not supported');
}
list($function, $algorithm) = static::$supported_algs[$alg];
switch($function) {
case 'hash_hmac':
return hash_hmac($algorithm, $msg, $key, true);
case 'openssl':
$signature = '';
$success = openssl_sign($msg, $signature, $key, $algorithm);
if (!$success) {
throw new DomainException("OpenSSL unable to sign data");
} else {
return $signature;
}
}
}
/**
* Verify a signature with the message, key and method. Not all methods
* are symmetric, so we must have a separate verify and sign method.
*
* @param string $msg The original message (header and body)
* @param string $signature The original signature
* @param string|resource $key For HS*, a string key works. for RS*, must be a resource of an openssl public key
* @param string $alg The algorithm
*
* @return bool
*
* @throws DomainException Invalid Algorithm or OpenSSL failure
*/
private static function verify($msg, $signature, $key, $alg)
{
if (empty(static::$supported_algs[$alg])) {
throw new DomainException('Algorithm not supported');
}
list($function, $algorithm) = static::$supported_algs[$alg];
switch($function) {
case 'openssl':
$success = openssl_verify($msg, $signature, $key, $algorithm);
if ($success === 1) {
return true;
} elseif ($success === 0) {
return false;
}
// returns 1 on success, 0 on failure, -1 on error.
throw new DomainException(
'OpenSSL error: ' . openssl_error_string()
);
case 'hash_hmac':
default:
$hash = hash_hmac($algorithm, $msg, $key, true);
if (function_exists('hash_equals')) {
return hash_equals($signature, $hash);
}
$len = min(static::safeStrlen($signature), static::safeStrlen($hash));
$status = 0;
for ($i = 0; $i < $len; $i++) {
$status |= (ord($signature[$i]) ^ ord($hash[$i]));
}
$status |= (static::safeStrlen($signature) ^ static::safeStrlen($hash));
return ($status === 0);
}
}
/**
* Decode a JSON string into a PHP object.
*
* @param string $input JSON string
*
* @return object Object representation of JSON string
*
* @throws DomainException Provided string was invalid JSON
*/
public static function jsonDecode($input)
{
if (version_compare(PHP_VERSION, '5.4.0', '>=') && !(defined('JSON_C_VERSION') && PHP_INT_SIZE > 4)) {
/** In PHP >=5.4.0, json_decode() accepts an options parameter, that allows you
* to specify that large ints (like Steam Transaction IDs) should be treated as
* strings, rather than the PHP default behaviour of converting them to floats.
*/
$obj = json_decode($input, false, 512, JSON_BIGINT_AS_STRING);
} else {
/** Not all servers will support that, however, so for older versions we must
* manually detect large ints in the JSON string and quote them (thus converting
*them to strings) before decoding, hence the preg_replace() call.
*/
$max_int_length = strlen((string) PHP_INT_MAX) - 1;
$json_without_bigints = preg_replace('/:\s*(-?\d{'.$max_int_length.',})/', ': "$1"', $input);
$obj = json_decode($json_without_bigints);
}
if (function_exists('json_last_error') && $errno = json_last_error()) {
static::handleJsonError($errno);
} elseif ($obj === null && $input !== 'null') {
throw new DomainException('Null result with non-null input');
}
return $obj;
}
/**
* Encode a PHP object into a JSON string.
*
* @param object|array $input A PHP object or array
*
* @return string JSON representation of the PHP object or array
*
* @throws DomainException Provided object could not be encoded to valid JSON
*/
public static function jsonEncode($input)
{
$json = json_encode($input);
if (function_exists('json_last_error') && $errno = json_last_error()) {
static::handleJsonError($errno);
} elseif ($json === 'null' && $input !== null) {
throw new DomainException('Null result with non-null input');
}
return $json;
}
/**
* Decode a string with URL-safe Base64.
*
* @param string $input A Base64 encoded string
*
* @return string A decoded string
*/
public static function urlsafeB64Decode($input)
{
$remainder = strlen($input) % 4;
if ($remainder) {
$padlen = 4 - $remainder;
$input .= str_repeat('=', $padlen);
}
return base64_decode(strtr($input, '-_', '+/'));
}
/**
* Encode a string with URL-safe Base64.
*
* @param string $input The string you want encoded
*
* @return string The base64 encode of what you passed in
*/
public static function urlsafeB64Encode($input)
{
return str_replace('=', '', strtr(base64_encode($input), '+/', '-_'));
}
/**
* Helper method to create a JSON error.
*
* @param int $errno An error number from json_last_error()
*
* @return void
*/
private static function handleJsonError($errno)
{
$messages = array(
JSON_ERROR_DEPTH => 'Maximum stack depth exceeded',
JSON_ERROR_STATE_MISMATCH => 'Invalid or malformed JSON',
JSON_ERROR_CTRL_CHAR => 'Unexpected control character found',
JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON',
JSON_ERROR_UTF8 => 'Malformed UTF-8 characters' //PHP >= 5.3.3
);
throw new DomainException(
isset($messages[$errno])
? $messages[$errno]
: 'Unknown JSON error: ' . $errno
);
}
/**
* Get the number of bytes in cryptographic strings.
*
* @param string
*
* @return int
*/
private static function safeStrlen($str)
{
if (function_exists('mb_strlen')) {
return mb_strlen($str, '8bit');
}
return strlen($str);
}
}

View File

@@ -0,0 +1,7 @@
<?php
namespace Firebase\JWT;
class SignatureInvalidException extends \UnexpectedValueException
{
}

View File

@@ -0,0 +1,203 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@@ -0,0 +1,23 @@
Google PHP API Client Services
==============================
## Requirements
[Google API PHP Client](https://github.com/googleapis/google-api-php-client/releases)
## Usage in v2 of Google API PHP Client
This library is automatically updated daily with new API changes, and tagged weekly.
It is installed as part of the
[Google API PHP Client](https://github.com/googleapis/google-api-php-client/releases)
library via Composer, which will pull down the most recent tag.
## Usage in v1
If you are currently using the [`v1-master`](https://github.com/googleapis/google-api-php-client/tree/v1-master)
branch of the client library, but want to use the latest API services, you can
do so by requiring this library directly into your project via the same composer command:
```sh
composer require google/apiclient-services:dev-master
```

View File

@@ -0,0 +1,19 @@
{
"name": "google/apiclient-services",
"type": "library",
"description": "Client library for Google APIs",
"keywords": ["google"],
"homepage": "http://developers.google.com/api-client-library/php",
"license": "Apache-2.0",
"require": {
"php": ">=5.4"
},
"require-dev": {
"phpunit/phpunit": "~4.8"
},
"autoload": {
"psr-0": {
"Google_Service_": "src"
}
}
}

View File

@@ -0,0 +1,950 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
/**
* Service definition for Drive (v3).
*
* <p>
* Manages files in Drive including uploading, downloading, searching, detecting
* changes, and updating sharing permissions.</p>
*
* <p>
* For more information about this service, see the API
* <a href="https://developers.google.com/drive/" target="_blank">Documentation</a>
* </p>
*
* @author Google, Inc.
*/
class Google_Service_Drive extends Google_Service
{
/** See, edit, create, and delete all of your Google Drive files. */
const DRIVE =
"https://www.googleapis.com/auth/drive";
/** View and manage its own configuration data in your Google Drive. */
const DRIVE_APPDATA =
"https://www.googleapis.com/auth/drive.appdata";
/** View and manage Google Drive files and folders that you have opened or created with this app. */
const DRIVE_FILE =
"https://www.googleapis.com/auth/drive.file";
/** View and manage metadata of files in your Google Drive. */
const DRIVE_METADATA =
"https://www.googleapis.com/auth/drive.metadata";
/** View metadata for files in your Google Drive. */
const DRIVE_METADATA_READONLY =
"https://www.googleapis.com/auth/drive.metadata.readonly";
/** View the photos, videos and albums in your Google Photos. */
const DRIVE_PHOTOS_READONLY =
"https://www.googleapis.com/auth/drive.photos.readonly";
/** See and download all your Google Drive files. */
const DRIVE_READONLY =
"https://www.googleapis.com/auth/drive.readonly";
/** Modify your Google Apps Script scripts' behavior. */
const DRIVE_SCRIPTS =
"https://www.googleapis.com/auth/drive.scripts";
public $about;
public $changes;
public $channels;
public $comments;
public $files;
public $permissions;
public $replies;
public $revisions;
public $teamdrives;
/**
* Constructs the internal representation of the Drive service.
*
* @param Google_Client $client
*/
public function __construct(Google_Client $client)
{
parent::__construct($client);
$this->rootUrl = 'https://www.googleapis.com/';
$this->servicePath = 'drive/v3/';
$this->version = 'v3';
$this->serviceName = 'drive';
$this->about = new Google_Service_Drive_Resource_About(
$this,
$this->serviceName,
'about',
array(
'methods' => array(
'get' => array(
'path' => 'about',
'httpMethod' => 'GET',
'parameters' => array(),
),
)
)
);
$this->changes = new Google_Service_Drive_Resource_Changes(
$this,
$this->serviceName,
'changes',
array(
'methods' => array(
'getStartPageToken' => array(
'path' => 'changes/startPageToken',
'httpMethod' => 'GET',
'parameters' => array(
'supportsTeamDrives' => array(
'location' => 'query',
'type' => 'boolean',
),
'teamDriveId' => array(
'location' => 'query',
'type' => 'string',
),
),
),'list' => array(
'path' => 'changes',
'httpMethod' => 'GET',
'parameters' => array(
'pageToken' => array(
'location' => 'query',
'type' => 'string',
'required' => true,
),
'includeCorpusRemovals' => array(
'location' => 'query',
'type' => 'boolean',
),
'includeRemoved' => array(
'location' => 'query',
'type' => 'boolean',
),
'includeTeamDriveItems' => array(
'location' => 'query',
'type' => 'boolean',
),
'pageSize' => array(
'location' => 'query',
'type' => 'integer',
),
'restrictToMyDrive' => array(
'location' => 'query',
'type' => 'boolean',
),
'spaces' => array(
'location' => 'query',
'type' => 'string',
),
'supportsTeamDrives' => array(
'location' => 'query',
'type' => 'boolean',
),
'teamDriveId' => array(
'location' => 'query',
'type' => 'string',
),
),
),'watch' => array(
'path' => 'changes/watch',
'httpMethod' => 'POST',
'parameters' => array(
'pageToken' => array(
'location' => 'query',
'type' => 'string',
'required' => true,
),
'includeCorpusRemovals' => array(
'location' => 'query',
'type' => 'boolean',
),
'includeRemoved' => array(
'location' => 'query',
'type' => 'boolean',
),
'includeTeamDriveItems' => array(
'location' => 'query',
'type' => 'boolean',
),
'pageSize' => array(
'location' => 'query',
'type' => 'integer',
),
'restrictToMyDrive' => array(
'location' => 'query',
'type' => 'boolean',
),
'spaces' => array(
'location' => 'query',
'type' => 'string',
),
'supportsTeamDrives' => array(
'location' => 'query',
'type' => 'boolean',
),
'teamDriveId' => array(
'location' => 'query',
'type' => 'string',
),
),
),
)
)
);
$this->channels = new Google_Service_Drive_Resource_Channels(
$this,
$this->serviceName,
'channels',
array(
'methods' => array(
'stop' => array(
'path' => 'channels/stop',
'httpMethod' => 'POST',
'parameters' => array(),
),
)
)
);
$this->comments = new Google_Service_Drive_Resource_Comments(
$this,
$this->serviceName,
'comments',
array(
'methods' => array(
'create' => array(
'path' => 'files/{fileId}/comments',
'httpMethod' => 'POST',
'parameters' => array(
'fileId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
),
),'delete' => array(
'path' => 'files/{fileId}/comments/{commentId}',
'httpMethod' => 'DELETE',
'parameters' => array(
'fileId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
'commentId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
),
),'get' => array(
'path' => 'files/{fileId}/comments/{commentId}',
'httpMethod' => 'GET',
'parameters' => array(
'fileId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
'commentId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
'includeDeleted' => array(
'location' => 'query',
'type' => 'boolean',
),
),
),'list' => array(
'path' => 'files/{fileId}/comments',
'httpMethod' => 'GET',
'parameters' => array(
'fileId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
'includeDeleted' => array(
'location' => 'query',
'type' => 'boolean',
),
'pageSize' => array(
'location' => 'query',
'type' => 'integer',
),
'pageToken' => array(
'location' => 'query',
'type' => 'string',
),
'startModifiedTime' => array(
'location' => 'query',
'type' => 'string',
),
),
),'update' => array(
'path' => 'files/{fileId}/comments/{commentId}',
'httpMethod' => 'PATCH',
'parameters' => array(
'fileId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
'commentId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
),
),
)
)
);
$this->files = new Google_Service_Drive_Resource_Files(
$this,
$this->serviceName,
'files',
array(
'methods' => array(
'copy' => array(
'path' => 'files/{fileId}/copy',
'httpMethod' => 'POST',
'parameters' => array(
'fileId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
'ignoreDefaultVisibility' => array(
'location' => 'query',
'type' => 'boolean',
),
'keepRevisionForever' => array(
'location' => 'query',
'type' => 'boolean',
),
'ocrLanguage' => array(
'location' => 'query',
'type' => 'string',
),
'supportsTeamDrives' => array(
'location' => 'query',
'type' => 'boolean',
),
),
),'create' => array(
'path' => 'files',
'httpMethod' => 'POST',
'parameters' => array(
'ignoreDefaultVisibility' => array(
'location' => 'query',
'type' => 'boolean',
),
'keepRevisionForever' => array(
'location' => 'query',
'type' => 'boolean',
),
'ocrLanguage' => array(
'location' => 'query',
'type' => 'string',
),
'supportsTeamDrives' => array(
'location' => 'query',
'type' => 'boolean',
),
'useContentAsIndexableText' => array(
'location' => 'query',
'type' => 'boolean',
),
),
),'delete' => array(
'path' => 'files/{fileId}',
'httpMethod' => 'DELETE',
'parameters' => array(
'fileId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
'supportsTeamDrives' => array(
'location' => 'query',
'type' => 'boolean',
),
),
),'emptyTrash' => array(
'path' => 'files/trash',
'httpMethod' => 'DELETE',
'parameters' => array(),
),'export' => array(
'path' => 'files/{fileId}/export',
'httpMethod' => 'GET',
'parameters' => array(
'fileId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
'mimeType' => array(
'location' => 'query',
'type' => 'string',
'required' => true,
),
),
),'generateIds' => array(
'path' => 'files/generateIds',
'httpMethod' => 'GET',
'parameters' => array(
'count' => array(
'location' => 'query',
'type' => 'integer',
),
'space' => array(
'location' => 'query',
'type' => 'string',
),
),
),'get' => array(
'path' => 'files/{fileId}',
'httpMethod' => 'GET',
'parameters' => array(
'fileId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
'acknowledgeAbuse' => array(
'location' => 'query',
'type' => 'boolean',
),
'supportsTeamDrives' => array(
'location' => 'query',
'type' => 'boolean',
),
),
),'list' => array(
'path' => 'files',
'httpMethod' => 'GET',
'parameters' => array(
'corpora' => array(
'location' => 'query',
'type' => 'string',
),
'corpus' => array(
'location' => 'query',
'type' => 'string',
),
'includeTeamDriveItems' => array(
'location' => 'query',
'type' => 'boolean',
),
'orderBy' => array(
'location' => 'query',
'type' => 'string',
),
'pageSize' => array(
'location' => 'query',
'type' => 'integer',
),
'pageToken' => array(
'location' => 'query',
'type' => 'string',
),
'q' => array(
'location' => 'query',
'type' => 'string',
),
'spaces' => array(
'location' => 'query',
'type' => 'string',
),
'supportsTeamDrives' => array(
'location' => 'query',
'type' => 'boolean',
),
'teamDriveId' => array(
'location' => 'query',
'type' => 'string',
),
),
),'update' => array(
'path' => 'files/{fileId}',
'httpMethod' => 'PATCH',
'parameters' => array(
'fileId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
'addParents' => array(
'location' => 'query',
'type' => 'string',
),
'keepRevisionForever' => array(
'location' => 'query',
'type' => 'boolean',
),
'ocrLanguage' => array(
'location' => 'query',
'type' => 'string',
),
'removeParents' => array(
'location' => 'query',
'type' => 'string',
),
'supportsTeamDrives' => array(
'location' => 'query',
'type' => 'boolean',
),
'useContentAsIndexableText' => array(
'location' => 'query',
'type' => 'boolean',
),
),
),'watch' => array(
'path' => 'files/{fileId}/watch',
'httpMethod' => 'POST',
'parameters' => array(
'fileId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
'acknowledgeAbuse' => array(
'location' => 'query',
'type' => 'boolean',
),
'supportsTeamDrives' => array(
'location' => 'query',
'type' => 'boolean',
),
),
),
)
)
);
$this->permissions = new Google_Service_Drive_Resource_Permissions(
$this,
$this->serviceName,
'permissions',
array(
'methods' => array(
'create' => array(
'path' => 'files/{fileId}/permissions',
'httpMethod' => 'POST',
'parameters' => array(
'fileId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
'emailMessage' => array(
'location' => 'query',
'type' => 'string',
),
'sendNotificationEmail' => array(
'location' => 'query',
'type' => 'boolean',
),
'supportsTeamDrives' => array(
'location' => 'query',
'type' => 'boolean',
),
'transferOwnership' => array(
'location' => 'query',
'type' => 'boolean',
),
'useDomainAdminAccess' => array(
'location' => 'query',
'type' => 'boolean',
),
),
),'delete' => array(
'path' => 'files/{fileId}/permissions/{permissionId}',
'httpMethod' => 'DELETE',
'parameters' => array(
'fileId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
'permissionId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
'supportsTeamDrives' => array(
'location' => 'query',
'type' => 'boolean',
),
'useDomainAdminAccess' => array(
'location' => 'query',
'type' => 'boolean',
),
),
),'get' => array(
'path' => 'files/{fileId}/permissions/{permissionId}',
'httpMethod' => 'GET',
'parameters' => array(
'fileId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
'permissionId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
'supportsTeamDrives' => array(
'location' => 'query',
'type' => 'boolean',
),
'useDomainAdminAccess' => array(
'location' => 'query',
'type' => 'boolean',
),
),
),'list' => array(
'path' => 'files/{fileId}/permissions',
'httpMethod' => 'GET',
'parameters' => array(
'fileId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
'pageSize' => array(
'location' => 'query',
'type' => 'integer',
),
'pageToken' => array(
'location' => 'query',
'type' => 'string',
),
'supportsTeamDrives' => array(
'location' => 'query',
'type' => 'boolean',
),
'useDomainAdminAccess' => array(
'location' => 'query',
'type' => 'boolean',
),
),
),'update' => array(
'path' => 'files/{fileId}/permissions/{permissionId}',
'httpMethod' => 'PATCH',
'parameters' => array(
'fileId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
'permissionId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
'removeExpiration' => array(
'location' => 'query',
'type' => 'boolean',
),
'supportsTeamDrives' => array(
'location' => 'query',
'type' => 'boolean',
),
'transferOwnership' => array(
'location' => 'query',
'type' => 'boolean',
),
'useDomainAdminAccess' => array(
'location' => 'query',
'type' => 'boolean',
),
),
),
)
)
);
$this->replies = new Google_Service_Drive_Resource_Replies(
$this,
$this->serviceName,
'replies',
array(
'methods' => array(
'create' => array(
'path' => 'files/{fileId}/comments/{commentId}/replies',
'httpMethod' => 'POST',
'parameters' => array(
'fileId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
'commentId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
),
),'delete' => array(
'path' => 'files/{fileId}/comments/{commentId}/replies/{replyId}',
'httpMethod' => 'DELETE',
'parameters' => array(
'fileId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
'commentId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
'replyId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
),
),'get' => array(
'path' => 'files/{fileId}/comments/{commentId}/replies/{replyId}',
'httpMethod' => 'GET',
'parameters' => array(
'fileId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
'commentId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
'replyId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
'includeDeleted' => array(
'location' => 'query',
'type' => 'boolean',
),
),
),'list' => array(
'path' => 'files/{fileId}/comments/{commentId}/replies',
'httpMethod' => 'GET',
'parameters' => array(
'fileId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
'commentId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
'includeDeleted' => array(
'location' => 'query',
'type' => 'boolean',
),
'pageSize' => array(
'location' => 'query',
'type' => 'integer',
),
'pageToken' => array(
'location' => 'query',
'type' => 'string',
),
),
),'update' => array(
'path' => 'files/{fileId}/comments/{commentId}/replies/{replyId}',
'httpMethod' => 'PATCH',
'parameters' => array(
'fileId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
'commentId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
'replyId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
),
),
)
)
);
$this->revisions = new Google_Service_Drive_Resource_Revisions(
$this,
$this->serviceName,
'revisions',
array(
'methods' => array(
'delete' => array(
'path' => 'files/{fileId}/revisions/{revisionId}',
'httpMethod' => 'DELETE',
'parameters' => array(
'fileId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
'revisionId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
),
),'get' => array(
'path' => 'files/{fileId}/revisions/{revisionId}',
'httpMethod' => 'GET',
'parameters' => array(
'fileId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
'revisionId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
'acknowledgeAbuse' => array(
'location' => 'query',
'type' => 'boolean',
),
),
),'list' => array(
'path' => 'files/{fileId}/revisions',
'httpMethod' => 'GET',
'parameters' => array(
'fileId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
'pageSize' => array(
'location' => 'query',
'type' => 'integer',
),
'pageToken' => array(
'location' => 'query',
'type' => 'string',
),
),
),'update' => array(
'path' => 'files/{fileId}/revisions/{revisionId}',
'httpMethod' => 'PATCH',
'parameters' => array(
'fileId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
'revisionId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
),
),
)
)
);
$this->teamdrives = new Google_Service_Drive_Resource_Teamdrives(
$this,
$this->serviceName,
'teamdrives',
array(
'methods' => array(
'create' => array(
'path' => 'teamdrives',
'httpMethod' => 'POST',
'parameters' => array(
'requestId' => array(
'location' => 'query',
'type' => 'string',
'required' => true,
),
),
),'delete' => array(
'path' => 'teamdrives/{teamDriveId}',
'httpMethod' => 'DELETE',
'parameters' => array(
'teamDriveId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
),
),'get' => array(
'path' => 'teamdrives/{teamDriveId}',
'httpMethod' => 'GET',
'parameters' => array(
'teamDriveId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
'useDomainAdminAccess' => array(
'location' => 'query',
'type' => 'boolean',
),
),
),'list' => array(
'path' => 'teamdrives',
'httpMethod' => 'GET',
'parameters' => array(
'pageSize' => array(
'location' => 'query',
'type' => 'integer',
),
'pageToken' => array(
'location' => 'query',
'type' => 'string',
),
'q' => array(
'location' => 'query',
'type' => 'string',
),
'useDomainAdminAccess' => array(
'location' => 'query',
'type' => 'boolean',
),
),
),'update' => array(
'path' => 'teamdrives/{teamDriveId}',
'httpMethod' => 'PATCH',
'parameters' => array(
'teamDriveId' => array(
'location' => 'path',
'type' => 'string',
'required' => true,
),
'useDomainAdminAccess' => array(
'location' => 'query',
'type' => 'boolean',
),
),
),
)
)
);
}
}

View File

@@ -0,0 +1,142 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
class Google_Service_Drive_About extends Google_Collection
{
protected $collection_key = 'teamDriveThemes';
public $appInstalled;
public $canCreateTeamDrives;
public $exportFormats;
public $folderColorPalette;
public $importFormats;
public $kind;
public $maxImportSizes;
public $maxUploadSize;
protected $storageQuotaType = 'Google_Service_Drive_AboutStorageQuota';
protected $storageQuotaDataType = '';
protected $teamDriveThemesType = 'Google_Service_Drive_AboutTeamDriveThemes';
protected $teamDriveThemesDataType = 'array';
protected $userType = 'Google_Service_Drive_User';
protected $userDataType = '';
public function setAppInstalled($appInstalled)
{
$this->appInstalled = $appInstalled;
}
public function getAppInstalled()
{
return $this->appInstalled;
}
public function setCanCreateTeamDrives($canCreateTeamDrives)
{
$this->canCreateTeamDrives = $canCreateTeamDrives;
}
public function getCanCreateTeamDrives()
{
return $this->canCreateTeamDrives;
}
public function setExportFormats($exportFormats)
{
$this->exportFormats = $exportFormats;
}
public function getExportFormats()
{
return $this->exportFormats;
}
public function setFolderColorPalette($folderColorPalette)
{
$this->folderColorPalette = $folderColorPalette;
}
public function getFolderColorPalette()
{
return $this->folderColorPalette;
}
public function setImportFormats($importFormats)
{
$this->importFormats = $importFormats;
}
public function getImportFormats()
{
return $this->importFormats;
}
public function setKind($kind)
{
$this->kind = $kind;
}
public function getKind()
{
return $this->kind;
}
public function setMaxImportSizes($maxImportSizes)
{
$this->maxImportSizes = $maxImportSizes;
}
public function getMaxImportSizes()
{
return $this->maxImportSizes;
}
public function setMaxUploadSize($maxUploadSize)
{
$this->maxUploadSize = $maxUploadSize;
}
public function getMaxUploadSize()
{
return $this->maxUploadSize;
}
/**
* @param Google_Service_Drive_AboutStorageQuota
*/
public function setStorageQuota(Google_Service_Drive_AboutStorageQuota $storageQuota)
{
$this->storageQuota = $storageQuota;
}
/**
* @return Google_Service_Drive_AboutStorageQuota
*/
public function getStorageQuota()
{
return $this->storageQuota;
}
/**
* @param Google_Service_Drive_AboutTeamDriveThemes
*/
public function setTeamDriveThemes($teamDriveThemes)
{
$this->teamDriveThemes = $teamDriveThemes;
}
/**
* @return Google_Service_Drive_AboutTeamDriveThemes
*/
public function getTeamDriveThemes()
{
return $this->teamDriveThemes;
}
/**
* @param Google_Service_Drive_User
*/
public function setUser(Google_Service_Drive_User $user)
{
$this->user = $user;
}
/**
* @return Google_Service_Drive_User
*/
public function getUser()
{
return $this->user;
}
}

View File

@@ -0,0 +1,57 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
class Google_Service_Drive_AboutStorageQuota extends Google_Model
{
public $limit;
public $usage;
public $usageInDrive;
public $usageInDriveTrash;
public function setLimit($limit)
{
$this->limit = $limit;
}
public function getLimit()
{
return $this->limit;
}
public function setUsage($usage)
{
$this->usage = $usage;
}
public function getUsage()
{
return $this->usage;
}
public function setUsageInDrive($usageInDrive)
{
$this->usageInDrive = $usageInDrive;
}
public function getUsageInDrive()
{
return $this->usageInDrive;
}
public function setUsageInDriveTrash($usageInDriveTrash)
{
$this->usageInDriveTrash = $usageInDriveTrash;
}
public function getUsageInDriveTrash()
{
return $this->usageInDriveTrash;
}
}

View File

@@ -0,0 +1,48 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
class Google_Service_Drive_AboutTeamDriveThemes extends Google_Model
{
public $backgroundImageLink;
public $colorRgb;
public $id;
public function setBackgroundImageLink($backgroundImageLink)
{
$this->backgroundImageLink = $backgroundImageLink;
}
public function getBackgroundImageLink()
{
return $this->backgroundImageLink;
}
public function setColorRgb($colorRgb)
{
$this->colorRgb = $colorRgb;
}
public function getColorRgb()
{
return $this->colorRgb;
}
public function setId($id)
{
$this->id = $id;
}
public function getId()
{
return $this->id;
}
}

View File

@@ -0,0 +1,107 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
class Google_Service_Drive_Change extends Google_Model
{
protected $fileType = 'Google_Service_Drive_DriveFile';
protected $fileDataType = '';
public $fileId;
public $kind;
public $removed;
protected $teamDriveType = 'Google_Service_Drive_TeamDrive';
protected $teamDriveDataType = '';
public $teamDriveId;
public $time;
public $type;
/**
* @param Google_Service_Drive_DriveFile
*/
public function setFile(Google_Service_Drive_DriveFile $file)
{
$this->file = $file;
}
/**
* @return Google_Service_Drive_DriveFile
*/
public function getFile()
{
return $this->file;
}
public function setFileId($fileId)
{
$this->fileId = $fileId;
}
public function getFileId()
{
return $this->fileId;
}
public function setKind($kind)
{
$this->kind = $kind;
}
public function getKind()
{
return $this->kind;
}
public function setRemoved($removed)
{
$this->removed = $removed;
}
public function getRemoved()
{
return $this->removed;
}
/**
* @param Google_Service_Drive_TeamDrive
*/
public function setTeamDrive(Google_Service_Drive_TeamDrive $teamDrive)
{
$this->teamDrive = $teamDrive;
}
/**
* @return Google_Service_Drive_TeamDrive
*/
public function getTeamDrive()
{
return $this->teamDrive;
}
public function setTeamDriveId($teamDriveId)
{
$this->teamDriveId = $teamDriveId;
}
public function getTeamDriveId()
{
return $this->teamDriveId;
}
public function setTime($time)
{
$this->time = $time;
}
public function getTime()
{
return $this->time;
}
public function setType($type)
{
$this->type = $type;
}
public function getType()
{
return $this->type;
}
}

View File

@@ -0,0 +1,65 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
class Google_Service_Drive_ChangeList extends Google_Collection
{
protected $collection_key = 'changes';
protected $changesType = 'Google_Service_Drive_Change';
protected $changesDataType = 'array';
public $kind;
public $newStartPageToken;
public $nextPageToken;
/**
* @param Google_Service_Drive_Change
*/
public function setChanges($changes)
{
$this->changes = $changes;
}
/**
* @return Google_Service_Drive_Change
*/
public function getChanges()
{
return $this->changes;
}
public function setKind($kind)
{
$this->kind = $kind;
}
public function getKind()
{
return $this->kind;
}
public function setNewStartPageToken($newStartPageToken)
{
$this->newStartPageToken = $newStartPageToken;
}
public function getNewStartPageToken()
{
return $this->newStartPageToken;
}
public function setNextPageToken($nextPageToken)
{
$this->nextPageToken = $nextPageToken;
}
public function getNextPageToken()
{
return $this->nextPageToken;
}
}

View File

@@ -0,0 +1,111 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
class Google_Service_Drive_Channel extends Google_Model
{
public $address;
public $expiration;
public $id;
public $kind;
public $params;
public $payload;
public $resourceId;
public $resourceUri;
public $token;
public $type;
public function setAddress($address)
{
$this->address = $address;
}
public function getAddress()
{
return $this->address;
}
public function setExpiration($expiration)
{
$this->expiration = $expiration;
}
public function getExpiration()
{
return $this->expiration;
}
public function setId($id)
{
$this->id = $id;
}
public function getId()
{
return $this->id;
}
public function setKind($kind)
{
$this->kind = $kind;
}
public function getKind()
{
return $this->kind;
}
public function setParams($params)
{
$this->params = $params;
}
public function getParams()
{
return $this->params;
}
public function setPayload($payload)
{
$this->payload = $payload;
}
public function getPayload()
{
return $this->payload;
}
public function setResourceId($resourceId)
{
$this->resourceId = $resourceId;
}
public function getResourceId()
{
return $this->resourceId;
}
public function setResourceUri($resourceUri)
{
$this->resourceUri = $resourceUri;
}
public function getResourceUri()
{
return $this->resourceUri;
}
public function setToken($token)
{
$this->token = $token;
}
public function getToken()
{
return $this->token;
}
public function setType($type)
{
$this->type = $type;
}
public function getType()
{
return $this->type;
}
}

View File

@@ -0,0 +1,151 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
class Google_Service_Drive_Comment extends Google_Collection
{
protected $collection_key = 'replies';
public $anchor;
protected $authorType = 'Google_Service_Drive_User';
protected $authorDataType = '';
public $content;
public $createdTime;
public $deleted;
public $htmlContent;
public $id;
public $kind;
public $modifiedTime;
protected $quotedFileContentType = 'Google_Service_Drive_CommentQuotedFileContent';
protected $quotedFileContentDataType = '';
protected $repliesType = 'Google_Service_Drive_Reply';
protected $repliesDataType = 'array';
public $resolved;
public function setAnchor($anchor)
{
$this->anchor = $anchor;
}
public function getAnchor()
{
return $this->anchor;
}
/**
* @param Google_Service_Drive_User
*/
public function setAuthor(Google_Service_Drive_User $author)
{
$this->author = $author;
}
/**
* @return Google_Service_Drive_User
*/
public function getAuthor()
{
return $this->author;
}
public function setContent($content)
{
$this->content = $content;
}
public function getContent()
{
return $this->content;
}
public function setCreatedTime($createdTime)
{
$this->createdTime = $createdTime;
}
public function getCreatedTime()
{
return $this->createdTime;
}
public function setDeleted($deleted)
{
$this->deleted = $deleted;
}
public function getDeleted()
{
return $this->deleted;
}
public function setHtmlContent($htmlContent)
{
$this->htmlContent = $htmlContent;
}
public function getHtmlContent()
{
return $this->htmlContent;
}
public function setId($id)
{
$this->id = $id;
}
public function getId()
{
return $this->id;
}
public function setKind($kind)
{
$this->kind = $kind;
}
public function getKind()
{
return $this->kind;
}
public function setModifiedTime($modifiedTime)
{
$this->modifiedTime = $modifiedTime;
}
public function getModifiedTime()
{
return $this->modifiedTime;
}
/**
* @param Google_Service_Drive_CommentQuotedFileContent
*/
public function setQuotedFileContent(Google_Service_Drive_CommentQuotedFileContent $quotedFileContent)
{
$this->quotedFileContent = $quotedFileContent;
}
/**
* @return Google_Service_Drive_CommentQuotedFileContent
*/
public function getQuotedFileContent()
{
return $this->quotedFileContent;
}
/**
* @param Google_Service_Drive_Reply
*/
public function setReplies($replies)
{
$this->replies = $replies;
}
/**
* @return Google_Service_Drive_Reply
*/
public function getReplies()
{
return $this->replies;
}
public function setResolved($resolved)
{
$this->resolved = $resolved;
}
public function getResolved()
{
return $this->resolved;
}
}

View File

@@ -0,0 +1,56 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
class Google_Service_Drive_CommentList extends Google_Collection
{
protected $collection_key = 'comments';
protected $commentsType = 'Google_Service_Drive_Comment';
protected $commentsDataType = 'array';
public $kind;
public $nextPageToken;
/**
* @param Google_Service_Drive_Comment
*/
public function setComments($comments)
{
$this->comments = $comments;
}
/**
* @return Google_Service_Drive_Comment
*/
public function getComments()
{
return $this->comments;
}
public function setKind($kind)
{
$this->kind = $kind;
}
public function getKind()
{
return $this->kind;
}
public function setNextPageToken($nextPageToken)
{
$this->nextPageToken = $nextPageToken;
}
public function getNextPageToken()
{
return $this->nextPageToken;
}
}

View File

@@ -0,0 +1,39 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
class Google_Service_Drive_CommentQuotedFileContent extends Google_Model
{
public $mimeType;
public $value;
public function setMimeType($mimeType)
{
$this->mimeType = $mimeType;
}
public function getMimeType()
{
return $this->mimeType;
}
public function setValue($value)
{
$this->value = $value;
}
public function getValue()
{
return $this->value;
}
}

View File

@@ -0,0 +1,571 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
class Google_Service_Drive_DriveFile extends Google_Collection
{
protected $collection_key = 'spaces';
public $appProperties;
protected $capabilitiesType = 'Google_Service_Drive_DriveFileCapabilities';
protected $capabilitiesDataType = '';
protected $contentHintsType = 'Google_Service_Drive_DriveFileContentHints';
protected $contentHintsDataType = '';
public $copyRequiresWriterPermission;
public $createdTime;
public $description;
public $explicitlyTrashed;
public $exportLinks;
public $fileExtension;
public $folderColorRgb;
public $fullFileExtension;
public $hasAugmentedPermissions;
public $hasThumbnail;
public $headRevisionId;
public $iconLink;
public $id;
protected $imageMediaMetadataType = 'Google_Service_Drive_DriveFileImageMediaMetadata';
protected $imageMediaMetadataDataType = '';
public $isAppAuthorized;
public $kind;
protected $lastModifyingUserType = 'Google_Service_Drive_User';
protected $lastModifyingUserDataType = '';
public $md5Checksum;
public $mimeType;
public $modifiedByMe;
public $modifiedByMeTime;
public $modifiedTime;
public $name;
public $originalFilename;
public $ownedByMe;
protected $ownersType = 'Google_Service_Drive_User';
protected $ownersDataType = 'array';
public $parents;
public $permissionIds;
protected $permissionsType = 'Google_Service_Drive_Permission';
protected $permissionsDataType = 'array';
public $properties;
public $quotaBytesUsed;
public $shared;
public $sharedWithMeTime;
protected $sharingUserType = 'Google_Service_Drive_User';
protected $sharingUserDataType = '';
public $size;
public $spaces;
public $starred;
public $teamDriveId;
public $thumbnailLink;
public $thumbnailVersion;
public $trashed;
public $trashedTime;
protected $trashingUserType = 'Google_Service_Drive_User';
protected $trashingUserDataType = '';
public $version;
protected $videoMediaMetadataType = 'Google_Service_Drive_DriveFileVideoMediaMetadata';
protected $videoMediaMetadataDataType = '';
public $viewedByMe;
public $viewedByMeTime;
public $viewersCanCopyContent;
public $webContentLink;
public $webViewLink;
public $writersCanShare;
public function setAppProperties($appProperties)
{
$this->appProperties = $appProperties;
}
public function getAppProperties()
{
return $this->appProperties;
}
/**
* @param Google_Service_Drive_DriveFileCapabilities
*/
public function setCapabilities(Google_Service_Drive_DriveFileCapabilities $capabilities)
{
$this->capabilities = $capabilities;
}
/**
* @return Google_Service_Drive_DriveFileCapabilities
*/
public function getCapabilities()
{
return $this->capabilities;
}
/**
* @param Google_Service_Drive_DriveFileContentHints
*/
public function setContentHints(Google_Service_Drive_DriveFileContentHints $contentHints)
{
$this->contentHints = $contentHints;
}
/**
* @return Google_Service_Drive_DriveFileContentHints
*/
public function getContentHints()
{
return $this->contentHints;
}
public function setCopyRequiresWriterPermission($copyRequiresWriterPermission)
{
$this->copyRequiresWriterPermission = $copyRequiresWriterPermission;
}
public function getCopyRequiresWriterPermission()
{
return $this->copyRequiresWriterPermission;
}
public function setCreatedTime($createdTime)
{
$this->createdTime = $createdTime;
}
public function getCreatedTime()
{
return $this->createdTime;
}
public function setDescription($description)
{
$this->description = $description;
}
public function getDescription()
{
return $this->description;
}
public function setExplicitlyTrashed($explicitlyTrashed)
{
$this->explicitlyTrashed = $explicitlyTrashed;
}
public function getExplicitlyTrashed()
{
return $this->explicitlyTrashed;
}
public function setExportLinks($exportLinks)
{
$this->exportLinks = $exportLinks;
}
public function getExportLinks()
{
return $this->exportLinks;
}
public function setFileExtension($fileExtension)
{
$this->fileExtension = $fileExtension;
}
public function getFileExtension()
{
return $this->fileExtension;
}
public function setFolderColorRgb($folderColorRgb)
{
$this->folderColorRgb = $folderColorRgb;
}
public function getFolderColorRgb()
{
return $this->folderColorRgb;
}
public function setFullFileExtension($fullFileExtension)
{
$this->fullFileExtension = $fullFileExtension;
}
public function getFullFileExtension()
{
return $this->fullFileExtension;
}
public function setHasAugmentedPermissions($hasAugmentedPermissions)
{
$this->hasAugmentedPermissions = $hasAugmentedPermissions;
}
public function getHasAugmentedPermissions()
{
return $this->hasAugmentedPermissions;
}
public function setHasThumbnail($hasThumbnail)
{
$this->hasThumbnail = $hasThumbnail;
}
public function getHasThumbnail()
{
return $this->hasThumbnail;
}
public function setHeadRevisionId($headRevisionId)
{
$this->headRevisionId = $headRevisionId;
}
public function getHeadRevisionId()
{
return $this->headRevisionId;
}
public function setIconLink($iconLink)
{
$this->iconLink = $iconLink;
}
public function getIconLink()
{
return $this->iconLink;
}
public function setId($id)
{
$this->id = $id;
}
public function getId()
{
return $this->id;
}
/**
* @param Google_Service_Drive_DriveFileImageMediaMetadata
*/
public function setImageMediaMetadata(Google_Service_Drive_DriveFileImageMediaMetadata $imageMediaMetadata)
{
$this->imageMediaMetadata = $imageMediaMetadata;
}
/**
* @return Google_Service_Drive_DriveFileImageMediaMetadata
*/
public function getImageMediaMetadata()
{
return $this->imageMediaMetadata;
}
public function setIsAppAuthorized($isAppAuthorized)
{
$this->isAppAuthorized = $isAppAuthorized;
}
public function getIsAppAuthorized()
{
return $this->isAppAuthorized;
}
public function setKind($kind)
{
$this->kind = $kind;
}
public function getKind()
{
return $this->kind;
}
/**
* @param Google_Service_Drive_User
*/
public function setLastModifyingUser(Google_Service_Drive_User $lastModifyingUser)
{
$this->lastModifyingUser = $lastModifyingUser;
}
/**
* @return Google_Service_Drive_User
*/
public function getLastModifyingUser()
{
return $this->lastModifyingUser;
}
public function setMd5Checksum($md5Checksum)
{
$this->md5Checksum = $md5Checksum;
}
public function getMd5Checksum()
{
return $this->md5Checksum;
}
public function setMimeType($mimeType)
{
$this->mimeType = $mimeType;
}
public function getMimeType()
{
return $this->mimeType;
}
public function setModifiedByMe($modifiedByMe)
{
$this->modifiedByMe = $modifiedByMe;
}
public function getModifiedByMe()
{
return $this->modifiedByMe;
}
public function setModifiedByMeTime($modifiedByMeTime)
{
$this->modifiedByMeTime = $modifiedByMeTime;
}
public function getModifiedByMeTime()
{
return $this->modifiedByMeTime;
}
public function setModifiedTime($modifiedTime)
{
$this->modifiedTime = $modifiedTime;
}
public function getModifiedTime()
{
return $this->modifiedTime;
}
public function setName($name)
{
$this->name = $name;
}
public function getName()
{
return $this->name;
}
public function setOriginalFilename($originalFilename)
{
$this->originalFilename = $originalFilename;
}
public function getOriginalFilename()
{
return $this->originalFilename;
}
public function setOwnedByMe($ownedByMe)
{
$this->ownedByMe = $ownedByMe;
}
public function getOwnedByMe()
{
return $this->ownedByMe;
}
/**
* @param Google_Service_Drive_User
*/
public function setOwners($owners)
{
$this->owners = $owners;
}
/**
* @return Google_Service_Drive_User
*/
public function getOwners()
{
return $this->owners;
}
public function setParents($parents)
{
$this->parents = $parents;
}
public function getParents()
{
return $this->parents;
}
public function setPermissionIds($permissionIds)
{
$this->permissionIds = $permissionIds;
}
public function getPermissionIds()
{
return $this->permissionIds;
}
/**
* @param Google_Service_Drive_Permission
*/
public function setPermissions($permissions)
{
$this->permissions = $permissions;
}
/**
* @return Google_Service_Drive_Permission
*/
public function getPermissions()
{
return $this->permissions;
}
public function setProperties($properties)
{
$this->properties = $properties;
}
public function getProperties()
{
return $this->properties;
}
public function setQuotaBytesUsed($quotaBytesUsed)
{
$this->quotaBytesUsed = $quotaBytesUsed;
}
public function getQuotaBytesUsed()
{
return $this->quotaBytesUsed;
}
public function setShared($shared)
{
$this->shared = $shared;
}
public function getShared()
{
return $this->shared;
}
public function setSharedWithMeTime($sharedWithMeTime)
{
$this->sharedWithMeTime = $sharedWithMeTime;
}
public function getSharedWithMeTime()
{
return $this->sharedWithMeTime;
}
/**
* @param Google_Service_Drive_User
*/
public function setSharingUser(Google_Service_Drive_User $sharingUser)
{
$this->sharingUser = $sharingUser;
}
/**
* @return Google_Service_Drive_User
*/
public function getSharingUser()
{
return $this->sharingUser;
}
public function setSize($size)
{
$this->size = $size;
}
public function getSize()
{
return $this->size;
}
public function setSpaces($spaces)
{
$this->spaces = $spaces;
}
public function getSpaces()
{
return $this->spaces;
}
public function setStarred($starred)
{
$this->starred = $starred;
}
public function getStarred()
{
return $this->starred;
}
public function setTeamDriveId($teamDriveId)
{
$this->teamDriveId = $teamDriveId;
}
public function getTeamDriveId()
{
return $this->teamDriveId;
}
public function setThumbnailLink($thumbnailLink)
{
$this->thumbnailLink = $thumbnailLink;
}
public function getThumbnailLink()
{
return $this->thumbnailLink;
}
public function setThumbnailVersion($thumbnailVersion)
{
$this->thumbnailVersion = $thumbnailVersion;
}
public function getThumbnailVersion()
{
return $this->thumbnailVersion;
}
public function setTrashed($trashed)
{
$this->trashed = $trashed;
}
public function getTrashed()
{
return $this->trashed;
}
public function setTrashedTime($trashedTime)
{
$this->trashedTime = $trashedTime;
}
public function getTrashedTime()
{
return $this->trashedTime;
}
/**
* @param Google_Service_Drive_User
*/
public function setTrashingUser(Google_Service_Drive_User $trashingUser)
{
$this->trashingUser = $trashingUser;
}
/**
* @return Google_Service_Drive_User
*/
public function getTrashingUser()
{
return $this->trashingUser;
}
public function setVersion($version)
{
$this->version = $version;
}
public function getVersion()
{
return $this->version;
}
/**
* @param Google_Service_Drive_DriveFileVideoMediaMetadata
*/
public function setVideoMediaMetadata(Google_Service_Drive_DriveFileVideoMediaMetadata $videoMediaMetadata)
{
$this->videoMediaMetadata = $videoMediaMetadata;
}
/**
* @return Google_Service_Drive_DriveFileVideoMediaMetadata
*/
public function getVideoMediaMetadata()
{
return $this->videoMediaMetadata;
}
public function setViewedByMe($viewedByMe)
{
$this->viewedByMe = $viewedByMe;
}
public function getViewedByMe()
{
return $this->viewedByMe;
}
public function setViewedByMeTime($viewedByMeTime)
{
$this->viewedByMeTime = $viewedByMeTime;
}
public function getViewedByMeTime()
{
return $this->viewedByMeTime;
}
public function setViewersCanCopyContent($viewersCanCopyContent)
{
$this->viewersCanCopyContent = $viewersCanCopyContent;
}
public function getViewersCanCopyContent()
{
return $this->viewersCanCopyContent;
}
public function setWebContentLink($webContentLink)
{
$this->webContentLink = $webContentLink;
}
public function getWebContentLink()
{
return $this->webContentLink;
}
public function setWebViewLink($webViewLink)
{
$this->webViewLink = $webViewLink;
}
public function getWebViewLink()
{
return $this->webViewLink;
}
public function setWritersCanShare($writersCanShare)
{
$this->writersCanShare = $writersCanShare;
}
public function getWritersCanShare()
{
return $this->writersCanShare;
}
}

View File

@@ -0,0 +1,237 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
class Google_Service_Drive_DriveFileCapabilities extends Google_Model
{
public $canAddChildren;
public $canChangeCopyRequiresWriterPermission;
public $canChangeViewersCanCopyContent;
public $canComment;
public $canCopy;
public $canDelete;
public $canDeleteChildren;
public $canDownload;
public $canEdit;
public $canListChildren;
public $canMoveChildrenOutOfTeamDrive;
public $canMoveChildrenWithinTeamDrive;
public $canMoveItemIntoTeamDrive;
public $canMoveItemOutOfTeamDrive;
public $canMoveItemWithinTeamDrive;
public $canMoveTeamDriveItem;
public $canReadRevisions;
public $canReadTeamDrive;
public $canRemoveChildren;
public $canRename;
public $canShare;
public $canTrash;
public $canTrashChildren;
public $canUntrash;
public function setCanAddChildren($canAddChildren)
{
$this->canAddChildren = $canAddChildren;
}
public function getCanAddChildren()
{
return $this->canAddChildren;
}
public function setCanChangeCopyRequiresWriterPermission($canChangeCopyRequiresWriterPermission)
{
$this->canChangeCopyRequiresWriterPermission = $canChangeCopyRequiresWriterPermission;
}
public function getCanChangeCopyRequiresWriterPermission()
{
return $this->canChangeCopyRequiresWriterPermission;
}
public function setCanChangeViewersCanCopyContent($canChangeViewersCanCopyContent)
{
$this->canChangeViewersCanCopyContent = $canChangeViewersCanCopyContent;
}
public function getCanChangeViewersCanCopyContent()
{
return $this->canChangeViewersCanCopyContent;
}
public function setCanComment($canComment)
{
$this->canComment = $canComment;
}
public function getCanComment()
{
return $this->canComment;
}
public function setCanCopy($canCopy)
{
$this->canCopy = $canCopy;
}
public function getCanCopy()
{
return $this->canCopy;
}
public function setCanDelete($canDelete)
{
$this->canDelete = $canDelete;
}
public function getCanDelete()
{
return $this->canDelete;
}
public function setCanDeleteChildren($canDeleteChildren)
{
$this->canDeleteChildren = $canDeleteChildren;
}
public function getCanDeleteChildren()
{
return $this->canDeleteChildren;
}
public function setCanDownload($canDownload)
{
$this->canDownload = $canDownload;
}
public function getCanDownload()
{
return $this->canDownload;
}
public function setCanEdit($canEdit)
{
$this->canEdit = $canEdit;
}
public function getCanEdit()
{
return $this->canEdit;
}
public function setCanListChildren($canListChildren)
{
$this->canListChildren = $canListChildren;
}
public function getCanListChildren()
{
return $this->canListChildren;
}
public function setCanMoveChildrenOutOfTeamDrive($canMoveChildrenOutOfTeamDrive)
{
$this->canMoveChildrenOutOfTeamDrive = $canMoveChildrenOutOfTeamDrive;
}
public function getCanMoveChildrenOutOfTeamDrive()
{
return $this->canMoveChildrenOutOfTeamDrive;
}
public function setCanMoveChildrenWithinTeamDrive($canMoveChildrenWithinTeamDrive)
{
$this->canMoveChildrenWithinTeamDrive = $canMoveChildrenWithinTeamDrive;
}
public function getCanMoveChildrenWithinTeamDrive()
{
return $this->canMoveChildrenWithinTeamDrive;
}
public function setCanMoveItemIntoTeamDrive($canMoveItemIntoTeamDrive)
{
$this->canMoveItemIntoTeamDrive = $canMoveItemIntoTeamDrive;
}
public function getCanMoveItemIntoTeamDrive()
{
return $this->canMoveItemIntoTeamDrive;
}
public function setCanMoveItemOutOfTeamDrive($canMoveItemOutOfTeamDrive)
{
$this->canMoveItemOutOfTeamDrive = $canMoveItemOutOfTeamDrive;
}
public function getCanMoveItemOutOfTeamDrive()
{
return $this->canMoveItemOutOfTeamDrive;
}
public function setCanMoveItemWithinTeamDrive($canMoveItemWithinTeamDrive)
{
$this->canMoveItemWithinTeamDrive = $canMoveItemWithinTeamDrive;
}
public function getCanMoveItemWithinTeamDrive()
{
return $this->canMoveItemWithinTeamDrive;
}
public function setCanMoveTeamDriveItem($canMoveTeamDriveItem)
{
$this->canMoveTeamDriveItem = $canMoveTeamDriveItem;
}
public function getCanMoveTeamDriveItem()
{
return $this->canMoveTeamDriveItem;
}
public function setCanReadRevisions($canReadRevisions)
{
$this->canReadRevisions = $canReadRevisions;
}
public function getCanReadRevisions()
{
return $this->canReadRevisions;
}
public function setCanReadTeamDrive($canReadTeamDrive)
{
$this->canReadTeamDrive = $canReadTeamDrive;
}
public function getCanReadTeamDrive()
{
return $this->canReadTeamDrive;
}
public function setCanRemoveChildren($canRemoveChildren)
{
$this->canRemoveChildren = $canRemoveChildren;
}
public function getCanRemoveChildren()
{
return $this->canRemoveChildren;
}
public function setCanRename($canRename)
{
$this->canRename = $canRename;
}
public function getCanRename()
{
return $this->canRename;
}
public function setCanShare($canShare)
{
$this->canShare = $canShare;
}
public function getCanShare()
{
return $this->canShare;
}
public function setCanTrash($canTrash)
{
$this->canTrash = $canTrash;
}
public function getCanTrash()
{
return $this->canTrash;
}
public function setCanTrashChildren($canTrashChildren)
{
$this->canTrashChildren = $canTrashChildren;
}
public function getCanTrashChildren()
{
return $this->canTrashChildren;
}
public function setCanUntrash($canUntrash)
{
$this->canUntrash = $canUntrash;
}
public function getCanUntrash()
{
return $this->canUntrash;
}
}

View File

@@ -0,0 +1,46 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
class Google_Service_Drive_DriveFileContentHints extends Google_Model
{
public $indexableText;
protected $thumbnailType = 'Google_Service_Drive_DriveFileContentHintsThumbnail';
protected $thumbnailDataType = '';
public function setIndexableText($indexableText)
{
$this->indexableText = $indexableText;
}
public function getIndexableText()
{
return $this->indexableText;
}
/**
* @param Google_Service_Drive_DriveFileContentHintsThumbnail
*/
public function setThumbnail(Google_Service_Drive_DriveFileContentHintsThumbnail $thumbnail)
{
$this->thumbnail = $thumbnail;
}
/**
* @return Google_Service_Drive_DriveFileContentHintsThumbnail
*/
public function getThumbnail()
{
return $this->thumbnail;
}
}

View File

@@ -0,0 +1,39 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
class Google_Service_Drive_DriveFileContentHintsThumbnail extends Google_Model
{
public $image;
public $mimeType;
public function setImage($image)
{
$this->image = $image;
}
public function getImage()
{
return $this->image;
}
public function setMimeType($mimeType)
{
$this->mimeType = $mimeType;
}
public function getMimeType()
{
return $this->mimeType;
}
}

View File

@@ -0,0 +1,217 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
class Google_Service_Drive_DriveFileImageMediaMetadata extends Google_Model
{
public $aperture;
public $cameraMake;
public $cameraModel;
public $colorSpace;
public $exposureBias;
public $exposureMode;
public $exposureTime;
public $flashUsed;
public $focalLength;
public $height;
public $isoSpeed;
public $lens;
protected $locationType = 'Google_Service_Drive_DriveFileImageMediaMetadataLocation';
protected $locationDataType = '';
public $maxApertureValue;
public $meteringMode;
public $rotation;
public $sensor;
public $subjectDistance;
public $time;
public $whiteBalance;
public $width;
public function setAperture($aperture)
{
$this->aperture = $aperture;
}
public function getAperture()
{
return $this->aperture;
}
public function setCameraMake($cameraMake)
{
$this->cameraMake = $cameraMake;
}
public function getCameraMake()
{
return $this->cameraMake;
}
public function setCameraModel($cameraModel)
{
$this->cameraModel = $cameraModel;
}
public function getCameraModel()
{
return $this->cameraModel;
}
public function setColorSpace($colorSpace)
{
$this->colorSpace = $colorSpace;
}
public function getColorSpace()
{
return $this->colorSpace;
}
public function setExposureBias($exposureBias)
{
$this->exposureBias = $exposureBias;
}
public function getExposureBias()
{
return $this->exposureBias;
}
public function setExposureMode($exposureMode)
{
$this->exposureMode = $exposureMode;
}
public function getExposureMode()
{
return $this->exposureMode;
}
public function setExposureTime($exposureTime)
{
$this->exposureTime = $exposureTime;
}
public function getExposureTime()
{
return $this->exposureTime;
}
public function setFlashUsed($flashUsed)
{
$this->flashUsed = $flashUsed;
}
public function getFlashUsed()
{
return $this->flashUsed;
}
public function setFocalLength($focalLength)
{
$this->focalLength = $focalLength;
}
public function getFocalLength()
{
return $this->focalLength;
}
public function setHeight($height)
{
$this->height = $height;
}
public function getHeight()
{
return $this->height;
}
public function setIsoSpeed($isoSpeed)
{
$this->isoSpeed = $isoSpeed;
}
public function getIsoSpeed()
{
return $this->isoSpeed;
}
public function setLens($lens)
{
$this->lens = $lens;
}
public function getLens()
{
return $this->lens;
}
/**
* @param Google_Service_Drive_DriveFileImageMediaMetadataLocation
*/
public function setLocation(Google_Service_Drive_DriveFileImageMediaMetadataLocation $location)
{
$this->location = $location;
}
/**
* @return Google_Service_Drive_DriveFileImageMediaMetadataLocation
*/
public function getLocation()
{
return $this->location;
}
public function setMaxApertureValue($maxApertureValue)
{
$this->maxApertureValue = $maxApertureValue;
}
public function getMaxApertureValue()
{
return $this->maxApertureValue;
}
public function setMeteringMode($meteringMode)
{
$this->meteringMode = $meteringMode;
}
public function getMeteringMode()
{
return $this->meteringMode;
}
public function setRotation($rotation)
{
$this->rotation = $rotation;
}
public function getRotation()
{
return $this->rotation;
}
public function setSensor($sensor)
{
$this->sensor = $sensor;
}
public function getSensor()
{
return $this->sensor;
}
public function setSubjectDistance($subjectDistance)
{
$this->subjectDistance = $subjectDistance;
}
public function getSubjectDistance()
{
return $this->subjectDistance;
}
public function setTime($time)
{
$this->time = $time;
}
public function getTime()
{
return $this->time;
}
public function setWhiteBalance($whiteBalance)
{
$this->whiteBalance = $whiteBalance;
}
public function getWhiteBalance()
{
return $this->whiteBalance;
}
public function setWidth($width)
{
$this->width = $width;
}
public function getWidth()
{
return $this->width;
}
}

View File

@@ -0,0 +1,48 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
class Google_Service_Drive_DriveFileImageMediaMetadataLocation extends Google_Model
{
public $altitude;
public $latitude;
public $longitude;
public function setAltitude($altitude)
{
$this->altitude = $altitude;
}
public function getAltitude()
{
return $this->altitude;
}
public function setLatitude($latitude)
{
$this->latitude = $latitude;
}
public function getLatitude()
{
return $this->latitude;
}
public function setLongitude($longitude)
{
$this->longitude = $longitude;
}
public function getLongitude()
{
return $this->longitude;
}
}

View File

@@ -0,0 +1,48 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
class Google_Service_Drive_DriveFileVideoMediaMetadata extends Google_Model
{
public $durationMillis;
public $height;
public $width;
public function setDurationMillis($durationMillis)
{
$this->durationMillis = $durationMillis;
}
public function getDurationMillis()
{
return $this->durationMillis;
}
public function setHeight($height)
{
$this->height = $height;
}
public function getHeight()
{
return $this->height;
}
public function setWidth($width)
{
$this->width = $width;
}
public function getWidth()
{
return $this->width;
}
}

View File

@@ -0,0 +1,65 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
class Google_Service_Drive_FileList extends Google_Collection
{
protected $collection_key = 'files';
protected $filesType = 'Google_Service_Drive_DriveFile';
protected $filesDataType = 'array';
public $incompleteSearch;
public $kind;
public $nextPageToken;
/**
* @param Google_Service_Drive_DriveFile
*/
public function setFiles($files)
{
$this->files = $files;
}
/**
* @return Google_Service_Drive_DriveFile
*/
public function getFiles()
{
return $this->files;
}
public function setIncompleteSearch($incompleteSearch)
{
$this->incompleteSearch = $incompleteSearch;
}
public function getIncompleteSearch()
{
return $this->incompleteSearch;
}
public function setKind($kind)
{
$this->kind = $kind;
}
public function getKind()
{
return $this->kind;
}
public function setNextPageToken($nextPageToken)
{
$this->nextPageToken = $nextPageToken;
}
public function getNextPageToken()
{
return $this->nextPageToken;
}
}

View File

@@ -0,0 +1,49 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
class Google_Service_Drive_GeneratedIds extends Google_Collection
{
protected $collection_key = 'ids';
public $ids;
public $kind;
public $space;
public function setIds($ids)
{
$this->ids = $ids;
}
public function getIds()
{
return $this->ids;
}
public function setKind($kind)
{
$this->kind = $kind;
}
public function getKind()
{
return $this->kind;
}
public function setSpace($space)
{
$this->space = $space;
}
public function getSpace()
{
return $this->space;
}
}

View File

@@ -0,0 +1,137 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
class Google_Service_Drive_Permission extends Google_Collection
{
protected $collection_key = 'teamDrivePermissionDetails';
public $allowFileDiscovery;
public $deleted;
public $displayName;
public $domain;
public $emailAddress;
public $expirationTime;
public $id;
public $kind;
public $photoLink;
public $role;
protected $teamDrivePermissionDetailsType = 'Google_Service_Drive_PermissionTeamDrivePermissionDetails';
protected $teamDrivePermissionDetailsDataType = 'array';
public $type;
public function setAllowFileDiscovery($allowFileDiscovery)
{
$this->allowFileDiscovery = $allowFileDiscovery;
}
public function getAllowFileDiscovery()
{
return $this->allowFileDiscovery;
}
public function setDeleted($deleted)
{
$this->deleted = $deleted;
}
public function getDeleted()
{
return $this->deleted;
}
public function setDisplayName($displayName)
{
$this->displayName = $displayName;
}
public function getDisplayName()
{
return $this->displayName;
}
public function setDomain($domain)
{
$this->domain = $domain;
}
public function getDomain()
{
return $this->domain;
}
public function setEmailAddress($emailAddress)
{
$this->emailAddress = $emailAddress;
}
public function getEmailAddress()
{
return $this->emailAddress;
}
public function setExpirationTime($expirationTime)
{
$this->expirationTime = $expirationTime;
}
public function getExpirationTime()
{
return $this->expirationTime;
}
public function setId($id)
{
$this->id = $id;
}
public function getId()
{
return $this->id;
}
public function setKind($kind)
{
$this->kind = $kind;
}
public function getKind()
{
return $this->kind;
}
public function setPhotoLink($photoLink)
{
$this->photoLink = $photoLink;
}
public function getPhotoLink()
{
return $this->photoLink;
}
public function setRole($role)
{
$this->role = $role;
}
public function getRole()
{
return $this->role;
}
/**
* @param Google_Service_Drive_PermissionTeamDrivePermissionDetails
*/
public function setTeamDrivePermissionDetails($teamDrivePermissionDetails)
{
$this->teamDrivePermissionDetails = $teamDrivePermissionDetails;
}
/**
* @return Google_Service_Drive_PermissionTeamDrivePermissionDetails
*/
public function getTeamDrivePermissionDetails()
{
return $this->teamDrivePermissionDetails;
}
public function setType($type)
{
$this->type = $type;
}
public function getType()
{
return $this->type;
}
}

View File

@@ -0,0 +1,56 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
class Google_Service_Drive_PermissionList extends Google_Collection
{
protected $collection_key = 'permissions';
public $kind;
public $nextPageToken;
protected $permissionsType = 'Google_Service_Drive_Permission';
protected $permissionsDataType = 'array';
public function setKind($kind)
{
$this->kind = $kind;
}
public function getKind()
{
return $this->kind;
}
public function setNextPageToken($nextPageToken)
{
$this->nextPageToken = $nextPageToken;
}
public function getNextPageToken()
{
return $this->nextPageToken;
}
/**
* @param Google_Service_Drive_Permission
*/
public function setPermissions($permissions)
{
$this->permissions = $permissions;
}
/**
* @return Google_Service_Drive_Permission
*/
public function getPermissions()
{
return $this->permissions;
}
}

View File

@@ -0,0 +1,57 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
class Google_Service_Drive_PermissionTeamDrivePermissionDetails extends Google_Model
{
public $inherited;
public $inheritedFrom;
public $role;
public $teamDrivePermissionType;
public function setInherited($inherited)
{
$this->inherited = $inherited;
}
public function getInherited()
{
return $this->inherited;
}
public function setInheritedFrom($inheritedFrom)
{
$this->inheritedFrom = $inheritedFrom;
}
public function getInheritedFrom()
{
return $this->inheritedFrom;
}
public function setRole($role)
{
$this->role = $role;
}
public function getRole()
{
return $this->role;
}
public function setTeamDrivePermissionType($teamDrivePermissionType)
{
$this->teamDrivePermissionType = $teamDrivePermissionType;
}
public function getTeamDrivePermissionType()
{
return $this->teamDrivePermissionType;
}
}

View File

@@ -0,0 +1,109 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
class Google_Service_Drive_Reply extends Google_Model
{
public $action;
protected $authorType = 'Google_Service_Drive_User';
protected $authorDataType = '';
public $content;
public $createdTime;
public $deleted;
public $htmlContent;
public $id;
public $kind;
public $modifiedTime;
public function setAction($action)
{
$this->action = $action;
}
public function getAction()
{
return $this->action;
}
/**
* @param Google_Service_Drive_User
*/
public function setAuthor(Google_Service_Drive_User $author)
{
$this->author = $author;
}
/**
* @return Google_Service_Drive_User
*/
public function getAuthor()
{
return $this->author;
}
public function setContent($content)
{
$this->content = $content;
}
public function getContent()
{
return $this->content;
}
public function setCreatedTime($createdTime)
{
$this->createdTime = $createdTime;
}
public function getCreatedTime()
{
return $this->createdTime;
}
public function setDeleted($deleted)
{
$this->deleted = $deleted;
}
public function getDeleted()
{
return $this->deleted;
}
public function setHtmlContent($htmlContent)
{
$this->htmlContent = $htmlContent;
}
public function getHtmlContent()
{
return $this->htmlContent;
}
public function setId($id)
{
$this->id = $id;
}
public function getId()
{
return $this->id;
}
public function setKind($kind)
{
$this->kind = $kind;
}
public function getKind()
{
return $this->kind;
}
public function setModifiedTime($modifiedTime)
{
$this->modifiedTime = $modifiedTime;
}
public function getModifiedTime()
{
return $this->modifiedTime;
}
}

View File

@@ -0,0 +1,56 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
class Google_Service_Drive_ReplyList extends Google_Collection
{
protected $collection_key = 'replies';
public $kind;
public $nextPageToken;
protected $repliesType = 'Google_Service_Drive_Reply';
protected $repliesDataType = 'array';
public function setKind($kind)
{
$this->kind = $kind;
}
public function getKind()
{
return $this->kind;
}
public function setNextPageToken($nextPageToken)
{
$this->nextPageToken = $nextPageToken;
}
public function getNextPageToken()
{
return $this->nextPageToken;
}
/**
* @param Google_Service_Drive_Reply
*/
public function setReplies($replies)
{
$this->replies = $replies;
}
/**
* @return Google_Service_Drive_Reply
*/
public function getReplies()
{
return $this->replies;
}
}

View File

@@ -0,0 +1,41 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
/**
* The "about" collection of methods.
* Typical usage is:
* <code>
* $driveService = new Google_Service_Drive(...);
* $about = $driveService->about;
* </code>
*/
class Google_Service_Drive_Resource_About extends Google_Service_Resource
{
/**
* Gets information about the user, the user's Drive, and system capabilities.
* (about.get)
*
* @param array $optParams Optional parameters.
* @return Google_Service_Drive_About
*/
public function get($optParams = array())
{
$params = array();
$params = array_merge($params, $optParams);
return $this->call('get', array($params), "Google_Service_Drive_About");
}
}

View File

@@ -0,0 +1,121 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
/**
* The "changes" collection of methods.
* Typical usage is:
* <code>
* $driveService = new Google_Service_Drive(...);
* $changes = $driveService->changes;
* </code>
*/
class Google_Service_Drive_Resource_Changes extends Google_Service_Resource
{
/**
* Gets the starting pageToken for listing future changes.
* (changes.getStartPageToken)
*
* @param array $optParams Optional parameters.
*
* @opt_param bool supportsTeamDrives Whether the requesting application
* supports Team Drives.
* @opt_param string teamDriveId The ID of the Team Drive for which the starting
* pageToken for listing future changes from that Team Drive will be returned.
* @return Google_Service_Drive_StartPageToken
*/
public function getStartPageToken($optParams = array())
{
$params = array();
$params = array_merge($params, $optParams);
return $this->call('getStartPageToken', array($params), "Google_Service_Drive_StartPageToken");
}
/**
* Lists the changes for a user or Team Drive. (changes.listChanges)
*
* @param string $pageToken The token for continuing a previous list request on
* the next page. This should be set to the value of 'nextPageToken' from the
* previous response or to the response from the getStartPageToken method.
* @param array $optParams Optional parameters.
*
* @opt_param bool includeCorpusRemovals Whether changes should include the file
* resource if the file is still accessible by the user at the time of the
* request, even when a file was removed from the list of changes and there will
* be no further change entries for this file.
* @opt_param bool includeRemoved Whether to include changes indicating that
* items have been removed from the list of changes, for example by deletion or
* loss of access.
* @opt_param bool includeTeamDriveItems Whether Team Drive files or changes
* should be included in results.
* @opt_param int pageSize The maximum number of changes to return per page.
* @opt_param bool restrictToMyDrive Whether to restrict the results to changes
* inside the My Drive hierarchy. This omits changes to files such as those in
* the Application Data folder or shared files which have not been added to My
* Drive.
* @opt_param string spaces A comma-separated list of spaces to query within the
* user corpus. Supported values are 'drive', 'appDataFolder' and 'photos'.
* @opt_param bool supportsTeamDrives Whether the requesting application
* supports Team Drives.
* @opt_param string teamDriveId The Team Drive from which changes will be
* returned. If specified the change IDs will be reflective of the Team Drive;
* use the combined Team Drive ID and change ID as an identifier.
* @return Google_Service_Drive_ChangeList
*/
public function listChanges($pageToken, $optParams = array())
{
$params = array('pageToken' => $pageToken);
$params = array_merge($params, $optParams);
return $this->call('list', array($params), "Google_Service_Drive_ChangeList");
}
/**
* Subscribes to changes for a user. (changes.watch)
*
* @param string $pageToken The token for continuing a previous list request on
* the next page. This should be set to the value of 'nextPageToken' from the
* previous response or to the response from the getStartPageToken method.
* @param Google_Service_Drive_Channel $postBody
* @param array $optParams Optional parameters.
*
* @opt_param bool includeCorpusRemovals Whether changes should include the file
* resource if the file is still accessible by the user at the time of the
* request, even when a file was removed from the list of changes and there will
* be no further change entries for this file.
* @opt_param bool includeRemoved Whether to include changes indicating that
* items have been removed from the list of changes, for example by deletion or
* loss of access.
* @opt_param bool includeTeamDriveItems Whether Team Drive files or changes
* should be included in results.
* @opt_param int pageSize The maximum number of changes to return per page.
* @opt_param bool restrictToMyDrive Whether to restrict the results to changes
* inside the My Drive hierarchy. This omits changes to files such as those in
* the Application Data folder or shared files which have not been added to My
* Drive.
* @opt_param string spaces A comma-separated list of spaces to query within the
* user corpus. Supported values are 'drive', 'appDataFolder' and 'photos'.
* @opt_param bool supportsTeamDrives Whether the requesting application
* supports Team Drives.
* @opt_param string teamDriveId The Team Drive from which changes will be
* returned. If specified the change IDs will be reflective of the Team Drive;
* use the combined Team Drive ID and change ID as an identifier.
* @return Google_Service_Drive_Channel
*/
public function watch($pageToken, Google_Service_Drive_Channel $postBody, $optParams = array())
{
$params = array('pageToken' => $pageToken, 'postBody' => $postBody);
$params = array_merge($params, $optParams);
return $this->call('watch', array($params), "Google_Service_Drive_Channel");
}
}

View File

@@ -0,0 +1,40 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
/**
* The "channels" collection of methods.
* Typical usage is:
* <code>
* $driveService = new Google_Service_Drive(...);
* $channels = $driveService->channels;
* </code>
*/
class Google_Service_Drive_Resource_Channels extends Google_Service_Resource
{
/**
* Stop watching resources through this channel (channels.stop)
*
* @param Google_Service_Drive_Channel $postBody
* @param array $optParams Optional parameters.
*/
public function stop(Google_Service_Drive_Channel $postBody, $optParams = array())
{
$params = array('postBody' => $postBody);
$params = array_merge($params, $optParams);
return $this->call('stop', array($params));
}
}

View File

@@ -0,0 +1,109 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
/**
* The "comments" collection of methods.
* Typical usage is:
* <code>
* $driveService = new Google_Service_Drive(...);
* $comments = $driveService->comments;
* </code>
*/
class Google_Service_Drive_Resource_Comments extends Google_Service_Resource
{
/**
* Creates a new comment on a file. (comments.create)
*
* @param string $fileId The ID of the file.
* @param Google_Service_Drive_Comment $postBody
* @param array $optParams Optional parameters.
* @return Google_Service_Drive_Comment
*/
public function create($fileId, Google_Service_Drive_Comment $postBody, $optParams = array())
{
$params = array('fileId' => $fileId, 'postBody' => $postBody);
$params = array_merge($params, $optParams);
return $this->call('create', array($params), "Google_Service_Drive_Comment");
}
/**
* Deletes a comment. (comments.delete)
*
* @param string $fileId The ID of the file.
* @param string $commentId The ID of the comment.
* @param array $optParams Optional parameters.
*/
public function delete($fileId, $commentId, $optParams = array())
{
$params = array('fileId' => $fileId, 'commentId' => $commentId);
$params = array_merge($params, $optParams);
return $this->call('delete', array($params));
}
/**
* Gets a comment by ID. (comments.get)
*
* @param string $fileId The ID of the file.
* @param string $commentId The ID of the comment.
* @param array $optParams Optional parameters.
*
* @opt_param bool includeDeleted Whether to return deleted comments. Deleted
* comments will not include their original content.
* @return Google_Service_Drive_Comment
*/
public function get($fileId, $commentId, $optParams = array())
{
$params = array('fileId' => $fileId, 'commentId' => $commentId);
$params = array_merge($params, $optParams);
return $this->call('get', array($params), "Google_Service_Drive_Comment");
}
/**
* Lists a file's comments. (comments.listComments)
*
* @param string $fileId The ID of the file.
* @param array $optParams Optional parameters.
*
* @opt_param bool includeDeleted Whether to include deleted comments. Deleted
* comments will not include their original content.
* @opt_param int pageSize The maximum number of comments to return per page.
* @opt_param string pageToken The token for continuing a previous list request
* on the next page. This should be set to the value of 'nextPageToken' from the
* previous response.
* @opt_param string startModifiedTime The minimum value of 'modifiedTime' for
* the result comments (RFC 3339 date-time).
* @return Google_Service_Drive_CommentList
*/
public function listComments($fileId, $optParams = array())
{
$params = array('fileId' => $fileId);
$params = array_merge($params, $optParams);
return $this->call('list', array($params), "Google_Service_Drive_CommentList");
}
/**
* Updates a comment with patch semantics. (comments.update)
*
* @param string $fileId The ID of the file.
* @param string $commentId The ID of the comment.
* @param Google_Service_Drive_Comment $postBody
* @param array $optParams Optional parameters.
* @return Google_Service_Drive_Comment
*/
public function update($fileId, $commentId, Google_Service_Drive_Comment $postBody, $optParams = array())
{
$params = array('fileId' => $fileId, 'commentId' => $commentId, 'postBody' => $postBody);
$params = array_merge($params, $optParams);
return $this->call('update', array($params), "Google_Service_Drive_Comment");
}
}

View File

@@ -0,0 +1,255 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
/**
* The "files" collection of methods.
* Typical usage is:
* <code>
* $driveService = new Google_Service_Drive(...);
* $files = $driveService->files;
* </code>
*/
class Google_Service_Drive_Resource_Files extends Google_Service_Resource
{
/**
* Creates a copy of a file and applies any requested updates with patch
* semantics. (files.copy)
*
* @param string $fileId The ID of the file.
* @param Google_Service_Drive_DriveFile $postBody
* @param array $optParams Optional parameters.
*
* @opt_param bool ignoreDefaultVisibility Whether to ignore the domain's
* default visibility settings for the created file. Domain administrators can
* choose to make all uploaded files visible to the domain by default; this
* parameter bypasses that behavior for the request. Permissions are still
* inherited from parent folders.
* @opt_param bool keepRevisionForever Whether to set the 'keepForever' field in
* the new head revision. This is only applicable to files with binary content
* in Drive.
* @opt_param string ocrLanguage A language hint for OCR processing during image
* import (ISO 639-1 code).
* @opt_param bool supportsTeamDrives Whether the requesting application
* supports Team Drives.
* @return Google_Service_Drive_DriveFile
*/
public function copy($fileId, Google_Service_Drive_DriveFile $postBody, $optParams = array())
{
$params = array('fileId' => $fileId, 'postBody' => $postBody);
$params = array_merge($params, $optParams);
return $this->call('copy', array($params), "Google_Service_Drive_DriveFile");
}
/**
* Creates a new file. (files.create)
*
* @param Google_Service_Drive_DriveFile $postBody
* @param array $optParams Optional parameters.
*
* @opt_param bool ignoreDefaultVisibility Whether to ignore the domain's
* default visibility settings for the created file. Domain administrators can
* choose to make all uploaded files visible to the domain by default; this
* parameter bypasses that behavior for the request. Permissions are still
* inherited from parent folders.
* @opt_param bool keepRevisionForever Whether to set the 'keepForever' field in
* the new head revision. This is only applicable to files with binary content
* in Drive.
* @opt_param string ocrLanguage A language hint for OCR processing during image
* import (ISO 639-1 code).
* @opt_param bool supportsTeamDrives Whether the requesting application
* supports Team Drives.
* @opt_param bool useContentAsIndexableText Whether to use the uploaded content
* as indexable text.
* @return Google_Service_Drive_DriveFile
*/
public function create(Google_Service_Drive_DriveFile $postBody, $optParams = array())
{
$params = array('postBody' => $postBody);
$params = array_merge($params, $optParams);
return $this->call('create', array($params), "Google_Service_Drive_DriveFile");
}
/**
* Permanently deletes a file owned by the user without moving it to the trash.
* If the file belongs to a Team Drive the user must be an organizer on the
* parent. If the target is a folder, all descendants owned by the user are also
* deleted. (files.delete)
*
* @param string $fileId The ID of the file.
* @param array $optParams Optional parameters.
*
* @opt_param bool supportsTeamDrives Whether the requesting application
* supports Team Drives.
*/
public function delete($fileId, $optParams = array())
{
$params = array('fileId' => $fileId);
$params = array_merge($params, $optParams);
return $this->call('delete', array($params));
}
/**
* Permanently deletes all of the user's trashed files. (files.emptyTrash)
*
* @param array $optParams Optional parameters.
*/
public function emptyTrash($optParams = array())
{
$params = array();
$params = array_merge($params, $optParams);
return $this->call('emptyTrash', array($params));
}
/**
* Exports a Google Doc to the requested MIME type and returns the exported
* content. Please note that the exported content is limited to 10MB.
* (files.export)
*
* @param string $fileId The ID of the file.
* @param string $mimeType The MIME type of the format requested for this
* export.
* @param array $optParams Optional parameters.
*/
public function export($fileId, $mimeType, $optParams = array())
{
$params = array('fileId' => $fileId, 'mimeType' => $mimeType);
$params = array_merge($params, $optParams);
return $this->call('export', array($params));
}
/**
* Generates a set of file IDs which can be provided in create requests.
* (files.generateIds)
*
* @param array $optParams Optional parameters.
*
* @opt_param int count The number of IDs to return.
* @opt_param string space The space in which the IDs can be used to create new
* files. Supported values are 'drive' and 'appDataFolder'.
* @return Google_Service_Drive_GeneratedIds
*/
public function generateIds($optParams = array())
{
$params = array();
$params = array_merge($params, $optParams);
return $this->call('generateIds', array($params), "Google_Service_Drive_GeneratedIds");
}
/**
* Gets a file's metadata or content by ID. (files.get)
*
* @param string $fileId The ID of the file.
* @param array $optParams Optional parameters.
*
* @opt_param bool acknowledgeAbuse Whether the user is acknowledging the risk
* of downloading known malware or other abusive files. This is only applicable
* when alt=media.
* @opt_param bool supportsTeamDrives Whether the requesting application
* supports Team Drives.
* @return Google_Service_Drive_DriveFile
*/
public function get($fileId, $optParams = array())
{
$params = array('fileId' => $fileId);
$params = array_merge($params, $optParams);
return $this->call('get', array($params), "Google_Service_Drive_DriveFile");
}
/**
* Lists or searches files. (files.listFiles)
*
* @param array $optParams Optional parameters.
*
* @opt_param string corpora Comma-separated list of bodies of items
* (files/documents) to which the query applies. Supported bodies are 'user',
* 'domain', 'teamDrive' and 'allTeamDrives'. 'allTeamDrives' must be combined
* with 'user'; all other values must be used in isolation. Prefer 'user' or
* 'teamDrive' to 'allTeamDrives' for efficiency.
* @opt_param string corpus The source of files to list. Deprecated: use
* 'corpora' instead.
* @opt_param bool includeTeamDriveItems Whether Team Drive items should be
* included in results.
* @opt_param string orderBy A comma-separated list of sort keys. Valid keys are
* 'createdTime', 'folder', 'modifiedByMeTime', 'modifiedTime', 'name',
* 'name_natural', 'quotaBytesUsed', 'recency', 'sharedWithMeTime', 'starred',
* and 'viewedByMeTime'. Each key sorts ascending by default, but may be
* reversed with the 'desc' modifier. Example usage:
* ?orderBy=folder,modifiedTime desc,name. Please note that there is a current
* limitation for users with approximately one million files in which the
* requested sort order is ignored.
* @opt_param int pageSize The maximum number of files to return per page.
* Partial or empty result pages are possible even before the end of the files
* list has been reached.
* @opt_param string pageToken The token for continuing a previous list request
* on the next page. This should be set to the value of 'nextPageToken' from the
* previous response.
* @opt_param string q A query for filtering the file results. See the "Search
* for Files" guide for supported syntax.
* @opt_param string spaces A comma-separated list of spaces to query within the
* corpus. Supported values are 'drive', 'appDataFolder' and 'photos'.
* @opt_param bool supportsTeamDrives Whether the requesting application
* supports Team Drives.
* @opt_param string teamDriveId ID of Team Drive to search.
* @return Google_Service_Drive_FileList
*/
public function listFiles($optParams = array())
{
$params = array();
$params = array_merge($params, $optParams);
return $this->call('list', array($params), "Google_Service_Drive_FileList");
}
/**
* Updates a file's metadata and/or content with patch semantics. (files.update)
*
* @param string $fileId The ID of the file.
* @param Google_Service_Drive_DriveFile $postBody
* @param array $optParams Optional parameters.
*
* @opt_param string addParents A comma-separated list of parent IDs to add.
* @opt_param bool keepRevisionForever Whether to set the 'keepForever' field in
* the new head revision. This is only applicable to files with binary content
* in Drive.
* @opt_param string ocrLanguage A language hint for OCR processing during image
* import (ISO 639-1 code).
* @opt_param string removeParents A comma-separated list of parent IDs to
* remove.
* @opt_param bool supportsTeamDrives Whether the requesting application
* supports Team Drives.
* @opt_param bool useContentAsIndexableText Whether to use the uploaded content
* as indexable text.
* @return Google_Service_Drive_DriveFile
*/
public function update($fileId, Google_Service_Drive_DriveFile $postBody, $optParams = array())
{
$params = array('fileId' => $fileId, 'postBody' => $postBody);
$params = array_merge($params, $optParams);
return $this->call('update', array($params), "Google_Service_Drive_DriveFile");
}
/**
* Subscribes to changes to a file (files.watch)
*
* @param string $fileId The ID of the file.
* @param Google_Service_Drive_Channel $postBody
* @param array $optParams Optional parameters.
*
* @opt_param bool acknowledgeAbuse Whether the user is acknowledging the risk
* of downloading known malware or other abusive files. This is only applicable
* when alt=media.
* @opt_param bool supportsTeamDrives Whether the requesting application
* supports Team Drives.
* @return Google_Service_Drive_Channel
*/
public function watch($fileId, Google_Service_Drive_Channel $postBody, $optParams = array())
{
$params = array('fileId' => $fileId, 'postBody' => $postBody);
$params = array_merge($params, $optParams);
return $this->call('watch', array($params), "Google_Service_Drive_Channel");
}
}

View File

@@ -0,0 +1,147 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
/**
* The "permissions" collection of methods.
* Typical usage is:
* <code>
* $driveService = new Google_Service_Drive(...);
* $permissions = $driveService->permissions;
* </code>
*/
class Google_Service_Drive_Resource_Permissions extends Google_Service_Resource
{
/**
* Creates a permission for a file or Team Drive. (permissions.create)
*
* @param string $fileId The ID of the file or Team Drive.
* @param Google_Service_Drive_Permission $postBody
* @param array $optParams Optional parameters.
*
* @opt_param string emailMessage A plain text custom message to include in the
* notification email.
* @opt_param bool sendNotificationEmail Whether to send a notification email
* when sharing to users or groups. This defaults to true for users and groups,
* and is not allowed for other requests. It must not be disabled for ownership
* transfers.
* @opt_param bool supportsTeamDrives Whether the requesting application
* supports Team Drives.
* @opt_param bool transferOwnership Whether to transfer ownership to the
* specified user and downgrade the current owner to a writer. This parameter is
* required as an acknowledgement of the side effect.
* @opt_param bool useDomainAdminAccess Issue the request as a domain
* administrator; if set to true, then the requester will be granted access if
* they are an administrator of the domain to which the item belongs.
* @return Google_Service_Drive_Permission
*/
public function create($fileId, Google_Service_Drive_Permission $postBody, $optParams = array())
{
$params = array('fileId' => $fileId, 'postBody' => $postBody);
$params = array_merge($params, $optParams);
return $this->call('create', array($params), "Google_Service_Drive_Permission");
}
/**
* Deletes a permission. (permissions.delete)
*
* @param string $fileId The ID of the file or Team Drive.
* @param string $permissionId The ID of the permission.
* @param array $optParams Optional parameters.
*
* @opt_param bool supportsTeamDrives Whether the requesting application
* supports Team Drives.
* @opt_param bool useDomainAdminAccess Issue the request as a domain
* administrator; if set to true, then the requester will be granted access if
* they are an administrator of the domain to which the item belongs.
*/
public function delete($fileId, $permissionId, $optParams = array())
{
$params = array('fileId' => $fileId, 'permissionId' => $permissionId);
$params = array_merge($params, $optParams);
return $this->call('delete', array($params));
}
/**
* Gets a permission by ID. (permissions.get)
*
* @param string $fileId The ID of the file.
* @param string $permissionId The ID of the permission.
* @param array $optParams Optional parameters.
*
* @opt_param bool supportsTeamDrives Whether the requesting application
* supports Team Drives.
* @opt_param bool useDomainAdminAccess Issue the request as a domain
* administrator; if set to true, then the requester will be granted access if
* they are an administrator of the domain to which the item belongs.
* @return Google_Service_Drive_Permission
*/
public function get($fileId, $permissionId, $optParams = array())
{
$params = array('fileId' => $fileId, 'permissionId' => $permissionId);
$params = array_merge($params, $optParams);
return $this->call('get', array($params), "Google_Service_Drive_Permission");
}
/**
* Lists a file's or Team Drive's permissions. (permissions.listPermissions)
*
* @param string $fileId The ID of the file or Team Drive.
* @param array $optParams Optional parameters.
*
* @opt_param int pageSize The maximum number of permissions to return per page.
* When not set for files in a Team Drive, at most 100 results will be returned.
* When not set for files that are not in a Team Drive, the entire list will be
* returned.
* @opt_param string pageToken The token for continuing a previous list request
* on the next page. This should be set to the value of 'nextPageToken' from the
* previous response.
* @opt_param bool supportsTeamDrives Whether the requesting application
* supports Team Drives.
* @opt_param bool useDomainAdminAccess Issue the request as a domain
* administrator; if set to true, then the requester will be granted access if
* they are an administrator of the domain to which the item belongs.
* @return Google_Service_Drive_PermissionList
*/
public function listPermissions($fileId, $optParams = array())
{
$params = array('fileId' => $fileId);
$params = array_merge($params, $optParams);
return $this->call('list', array($params), "Google_Service_Drive_PermissionList");
}
/**
* Updates a permission with patch semantics. (permissions.update)
*
* @param string $fileId The ID of the file or Team Drive.
* @param string $permissionId The ID of the permission.
* @param Google_Service_Drive_Permission $postBody
* @param array $optParams Optional parameters.
*
* @opt_param bool removeExpiration Whether to remove the expiration date.
* @opt_param bool supportsTeamDrives Whether the requesting application
* supports Team Drives.
* @opt_param bool transferOwnership Whether to transfer ownership to the
* specified user and downgrade the current owner to a writer. This parameter is
* required as an acknowledgement of the side effect.
* @opt_param bool useDomainAdminAccess Issue the request as a domain
* administrator; if set to true, then the requester will be granted access if
* they are an administrator of the domain to which the item belongs.
* @return Google_Service_Drive_Permission
*/
public function update($fileId, $permissionId, Google_Service_Drive_Permission $postBody, $optParams = array())
{
$params = array('fileId' => $fileId, 'permissionId' => $permissionId, 'postBody' => $postBody);
$params = array_merge($params, $optParams);
return $this->call('update', array($params), "Google_Service_Drive_Permission");
}
}

View File

@@ -0,0 +1,112 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
/**
* The "replies" collection of methods.
* Typical usage is:
* <code>
* $driveService = new Google_Service_Drive(...);
* $replies = $driveService->replies;
* </code>
*/
class Google_Service_Drive_Resource_Replies extends Google_Service_Resource
{
/**
* Creates a new reply to a comment. (replies.create)
*
* @param string $fileId The ID of the file.
* @param string $commentId The ID of the comment.
* @param Google_Service_Drive_Reply $postBody
* @param array $optParams Optional parameters.
* @return Google_Service_Drive_Reply
*/
public function create($fileId, $commentId, Google_Service_Drive_Reply $postBody, $optParams = array())
{
$params = array('fileId' => $fileId, 'commentId' => $commentId, 'postBody' => $postBody);
$params = array_merge($params, $optParams);
return $this->call('create', array($params), "Google_Service_Drive_Reply");
}
/**
* Deletes a reply. (replies.delete)
*
* @param string $fileId The ID of the file.
* @param string $commentId The ID of the comment.
* @param string $replyId The ID of the reply.
* @param array $optParams Optional parameters.
*/
public function delete($fileId, $commentId, $replyId, $optParams = array())
{
$params = array('fileId' => $fileId, 'commentId' => $commentId, 'replyId' => $replyId);
$params = array_merge($params, $optParams);
return $this->call('delete', array($params));
}
/**
* Gets a reply by ID. (replies.get)
*
* @param string $fileId The ID of the file.
* @param string $commentId The ID of the comment.
* @param string $replyId The ID of the reply.
* @param array $optParams Optional parameters.
*
* @opt_param bool includeDeleted Whether to return deleted replies. Deleted
* replies will not include their original content.
* @return Google_Service_Drive_Reply
*/
public function get($fileId, $commentId, $replyId, $optParams = array())
{
$params = array('fileId' => $fileId, 'commentId' => $commentId, 'replyId' => $replyId);
$params = array_merge($params, $optParams);
return $this->call('get', array($params), "Google_Service_Drive_Reply");
}
/**
* Lists a comment's replies. (replies.listReplies)
*
* @param string $fileId The ID of the file.
* @param string $commentId The ID of the comment.
* @param array $optParams Optional parameters.
*
* @opt_param bool includeDeleted Whether to include deleted replies. Deleted
* replies will not include their original content.
* @opt_param int pageSize The maximum number of replies to return per page.
* @opt_param string pageToken The token for continuing a previous list request
* on the next page. This should be set to the value of 'nextPageToken' from the
* previous response.
* @return Google_Service_Drive_ReplyList
*/
public function listReplies($fileId, $commentId, $optParams = array())
{
$params = array('fileId' => $fileId, 'commentId' => $commentId);
$params = array_merge($params, $optParams);
return $this->call('list', array($params), "Google_Service_Drive_ReplyList");
}
/**
* Updates a reply with patch semantics. (replies.update)
*
* @param string $fileId The ID of the file.
* @param string $commentId The ID of the comment.
* @param string $replyId The ID of the reply.
* @param Google_Service_Drive_Reply $postBody
* @param array $optParams Optional parameters.
* @return Google_Service_Drive_Reply
*/
public function update($fileId, $commentId, $replyId, Google_Service_Drive_Reply $postBody, $optParams = array())
{
$params = array('fileId' => $fileId, 'commentId' => $commentId, 'replyId' => $replyId, 'postBody' => $postBody);
$params = array_merge($params, $optParams);
return $this->call('update', array($params), "Google_Service_Drive_Reply");
}
}

View File

@@ -0,0 +1,93 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
/**
* The "revisions" collection of methods.
* Typical usage is:
* <code>
* $driveService = new Google_Service_Drive(...);
* $revisions = $driveService->revisions;
* </code>
*/
class Google_Service_Drive_Resource_Revisions extends Google_Service_Resource
{
/**
* Permanently deletes a revision. This method is only applicable to files with
* binary content in Drive. (revisions.delete)
*
* @param string $fileId The ID of the file.
* @param string $revisionId The ID of the revision.
* @param array $optParams Optional parameters.
*/
public function delete($fileId, $revisionId, $optParams = array())
{
$params = array('fileId' => $fileId, 'revisionId' => $revisionId);
$params = array_merge($params, $optParams);
return $this->call('delete', array($params));
}
/**
* Gets a revision's metadata or content by ID. (revisions.get)
*
* @param string $fileId The ID of the file.
* @param string $revisionId The ID of the revision.
* @param array $optParams Optional parameters.
*
* @opt_param bool acknowledgeAbuse Whether the user is acknowledging the risk
* of downloading known malware or other abusive files. This is only applicable
* when alt=media.
* @return Google_Service_Drive_Revision
*/
public function get($fileId, $revisionId, $optParams = array())
{
$params = array('fileId' => $fileId, 'revisionId' => $revisionId);
$params = array_merge($params, $optParams);
return $this->call('get', array($params), "Google_Service_Drive_Revision");
}
/**
* Lists a file's revisions. (revisions.listRevisions)
*
* @param string $fileId The ID of the file.
* @param array $optParams Optional parameters.
*
* @opt_param int pageSize The maximum number of revisions to return per page.
* @opt_param string pageToken The token for continuing a previous list request
* on the next page. This should be set to the value of 'nextPageToken' from the
* previous response.
* @return Google_Service_Drive_RevisionList
*/
public function listRevisions($fileId, $optParams = array())
{
$params = array('fileId' => $fileId);
$params = array_merge($params, $optParams);
return $this->call('list', array($params), "Google_Service_Drive_RevisionList");
}
/**
* Updates a revision with patch semantics. (revisions.update)
*
* @param string $fileId The ID of the file.
* @param string $revisionId The ID of the revision.
* @param Google_Service_Drive_Revision $postBody
* @param array $optParams Optional parameters.
* @return Google_Service_Drive_Revision
*/
public function update($fileId, $revisionId, Google_Service_Drive_Revision $postBody, $optParams = array())
{
$params = array('fileId' => $fileId, 'revisionId' => $revisionId, 'postBody' => $postBody);
$params = array_merge($params, $optParams);
return $this->call('update', array($params), "Google_Service_Drive_Revision");
}
}

View File

@@ -0,0 +1,113 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
/**
* The "teamdrives" collection of methods.
* Typical usage is:
* <code>
* $driveService = new Google_Service_Drive(...);
* $teamdrives = $driveService->teamdrives;
* </code>
*/
class Google_Service_Drive_Resource_Teamdrives extends Google_Service_Resource
{
/**
* Creates a new Team Drive. (teamdrives.create)
*
* @param string $requestId An ID, such as a random UUID, which uniquely
* identifies this user's request for idempotent creation of a Team Drive. A
* repeated request by the same user and with the same request ID will avoid
* creating duplicates by attempting to create the same Team Drive. If the Team
* Drive already exists a 409 error will be returned.
* @param Google_Service_Drive_TeamDrive $postBody
* @param array $optParams Optional parameters.
* @return Google_Service_Drive_TeamDrive
*/
public function create($requestId, Google_Service_Drive_TeamDrive $postBody, $optParams = array())
{
$params = array('requestId' => $requestId, 'postBody' => $postBody);
$params = array_merge($params, $optParams);
return $this->call('create', array($params), "Google_Service_Drive_TeamDrive");
}
/**
* Permanently deletes a Team Drive for which the user is an organizer. The Team
* Drive cannot contain any untrashed items. (teamdrives.delete)
*
* @param string $teamDriveId The ID of the Team Drive
* @param array $optParams Optional parameters.
*/
public function delete($teamDriveId, $optParams = array())
{
$params = array('teamDriveId' => $teamDriveId);
$params = array_merge($params, $optParams);
return $this->call('delete', array($params));
}
/**
* Gets a Team Drive's metadata by ID. (teamdrives.get)
*
* @param string $teamDriveId The ID of the Team Drive
* @param array $optParams Optional parameters.
*
* @opt_param bool useDomainAdminAccess Issue the request as a domain
* administrator; if set to true, then the requester will be granted access if
* they are an administrator of the domain to which the Team Drive belongs.
* @return Google_Service_Drive_TeamDrive
*/
public function get($teamDriveId, $optParams = array())
{
$params = array('teamDriveId' => $teamDriveId);
$params = array_merge($params, $optParams);
return $this->call('get', array($params), "Google_Service_Drive_TeamDrive");
}
/**
* Lists the user's Team Drives. (teamdrives.listTeamdrives)
*
* @param array $optParams Optional parameters.
*
* @opt_param int pageSize Maximum number of Team Drives to return.
* @opt_param string pageToken Page token for Team Drives.
* @opt_param string q Query string for searching Team Drives.
* @opt_param bool useDomainAdminAccess Issue the request as a domain
* administrator; if set to true, then all Team Drives of the domain in which
* the requester is an administrator are returned.
* @return Google_Service_Drive_TeamDriveList
*/
public function listTeamdrives($optParams = array())
{
$params = array();
$params = array_merge($params, $optParams);
return $this->call('list', array($params), "Google_Service_Drive_TeamDriveList");
}
/**
* Updates a Team Drive's metadata (teamdrives.update)
*
* @param string $teamDriveId The ID of the Team Drive
* @param Google_Service_Drive_TeamDrive $postBody
* @param array $optParams Optional parameters.
*
* @opt_param bool useDomainAdminAccess Issue the request as a domain
* administrator; if set to true, then the requester will be granted access if
* they are an administrator of the domain to which the Team Drive belongs.
* @return Google_Service_Drive_TeamDrive
*/
public function update($teamDriveId, Google_Service_Drive_TeamDrive $postBody, $optParams = array())
{
$params = array('teamDriveId' => $teamDriveId, 'postBody' => $postBody);
$params = array_merge($params, $optParams);
return $this->call('update', array($params), "Google_Service_Drive_TeamDrive");
}
}

View File

@@ -0,0 +1,145 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
class Google_Service_Drive_Revision extends Google_Model
{
public $exportLinks;
public $id;
public $keepForever;
public $kind;
protected $lastModifyingUserType = 'Google_Service_Drive_User';
protected $lastModifyingUserDataType = '';
public $md5Checksum;
public $mimeType;
public $modifiedTime;
public $originalFilename;
public $publishAuto;
public $published;
public $publishedOutsideDomain;
public $size;
public function setExportLinks($exportLinks)
{
$this->exportLinks = $exportLinks;
}
public function getExportLinks()
{
return $this->exportLinks;
}
public function setId($id)
{
$this->id = $id;
}
public function getId()
{
return $this->id;
}
public function setKeepForever($keepForever)
{
$this->keepForever = $keepForever;
}
public function getKeepForever()
{
return $this->keepForever;
}
public function setKind($kind)
{
$this->kind = $kind;
}
public function getKind()
{
return $this->kind;
}
/**
* @param Google_Service_Drive_User
*/
public function setLastModifyingUser(Google_Service_Drive_User $lastModifyingUser)
{
$this->lastModifyingUser = $lastModifyingUser;
}
/**
* @return Google_Service_Drive_User
*/
public function getLastModifyingUser()
{
return $this->lastModifyingUser;
}
public function setMd5Checksum($md5Checksum)
{
$this->md5Checksum = $md5Checksum;
}
public function getMd5Checksum()
{
return $this->md5Checksum;
}
public function setMimeType($mimeType)
{
$this->mimeType = $mimeType;
}
public function getMimeType()
{
return $this->mimeType;
}
public function setModifiedTime($modifiedTime)
{
$this->modifiedTime = $modifiedTime;
}
public function getModifiedTime()
{
return $this->modifiedTime;
}
public function setOriginalFilename($originalFilename)
{
$this->originalFilename = $originalFilename;
}
public function getOriginalFilename()
{
return $this->originalFilename;
}
public function setPublishAuto($publishAuto)
{
$this->publishAuto = $publishAuto;
}
public function getPublishAuto()
{
return $this->publishAuto;
}
public function setPublished($published)
{
$this->published = $published;
}
public function getPublished()
{
return $this->published;
}
public function setPublishedOutsideDomain($publishedOutsideDomain)
{
$this->publishedOutsideDomain = $publishedOutsideDomain;
}
public function getPublishedOutsideDomain()
{
return $this->publishedOutsideDomain;
}
public function setSize($size)
{
$this->size = $size;
}
public function getSize()
{
return $this->size;
}
}

View File

@@ -0,0 +1,56 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
class Google_Service_Drive_RevisionList extends Google_Collection
{
protected $collection_key = 'revisions';
public $kind;
public $nextPageToken;
protected $revisionsType = 'Google_Service_Drive_Revision';
protected $revisionsDataType = 'array';
public function setKind($kind)
{
$this->kind = $kind;
}
public function getKind()
{
return $this->kind;
}
public function setNextPageToken($nextPageToken)
{
$this->nextPageToken = $nextPageToken;
}
public function getNextPageToken()
{
return $this->nextPageToken;
}
/**
* @param Google_Service_Drive_Revision
*/
public function setRevisions($revisions)
{
$this->revisions = $revisions;
}
/**
* @return Google_Service_Drive_Revision
*/
public function getRevisions()
{
return $this->revisions;
}
}

View File

@@ -0,0 +1,39 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
class Google_Service_Drive_StartPageToken extends Google_Model
{
public $kind;
public $startPageToken;
public function setKind($kind)
{
$this->kind = $kind;
}
public function getKind()
{
return $this->kind;
}
public function setStartPageToken($startPageToken)
{
$this->startPageToken = $startPageToken;
}
public function getStartPageToken()
{
return $this->startPageToken;
}
}

View File

@@ -0,0 +1,132 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
class Google_Service_Drive_TeamDrive extends Google_Model
{
protected $backgroundImageFileType = 'Google_Service_Drive_TeamDriveBackgroundImageFile';
protected $backgroundImageFileDataType = '';
public $backgroundImageLink;
protected $capabilitiesType = 'Google_Service_Drive_TeamDriveCapabilities';
protected $capabilitiesDataType = '';
public $colorRgb;
public $createdTime;
public $id;
public $kind;
public $name;
protected $restrictionsType = 'Google_Service_Drive_TeamDriveRestrictions';
protected $restrictionsDataType = '';
public $themeId;
/**
* @param Google_Service_Drive_TeamDriveBackgroundImageFile
*/
public function setBackgroundImageFile(Google_Service_Drive_TeamDriveBackgroundImageFile $backgroundImageFile)
{
$this->backgroundImageFile = $backgroundImageFile;
}
/**
* @return Google_Service_Drive_TeamDriveBackgroundImageFile
*/
public function getBackgroundImageFile()
{
return $this->backgroundImageFile;
}
public function setBackgroundImageLink($backgroundImageLink)
{
$this->backgroundImageLink = $backgroundImageLink;
}
public function getBackgroundImageLink()
{
return $this->backgroundImageLink;
}
/**
* @param Google_Service_Drive_TeamDriveCapabilities
*/
public function setCapabilities(Google_Service_Drive_TeamDriveCapabilities $capabilities)
{
$this->capabilities = $capabilities;
}
/**
* @return Google_Service_Drive_TeamDriveCapabilities
*/
public function getCapabilities()
{
return $this->capabilities;
}
public function setColorRgb($colorRgb)
{
$this->colorRgb = $colorRgb;
}
public function getColorRgb()
{
return $this->colorRgb;
}
public function setCreatedTime($createdTime)
{
$this->createdTime = $createdTime;
}
public function getCreatedTime()
{
return $this->createdTime;
}
public function setId($id)
{
$this->id = $id;
}
public function getId()
{
return $this->id;
}
public function setKind($kind)
{
$this->kind = $kind;
}
public function getKind()
{
return $this->kind;
}
public function setName($name)
{
$this->name = $name;
}
public function getName()
{
return $this->name;
}
/**
* @param Google_Service_Drive_TeamDriveRestrictions
*/
public function setRestrictions(Google_Service_Drive_TeamDriveRestrictions $restrictions)
{
$this->restrictions = $restrictions;
}
/**
* @return Google_Service_Drive_TeamDriveRestrictions
*/
public function getRestrictions()
{
return $this->restrictions;
}
public function setThemeId($themeId)
{
$this->themeId = $themeId;
}
public function getThemeId()
{
return $this->themeId;
}
}

View File

@@ -0,0 +1,57 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
class Google_Service_Drive_TeamDriveBackgroundImageFile extends Google_Model
{
public $id;
public $width;
public $xCoordinate;
public $yCoordinate;
public function setId($id)
{
$this->id = $id;
}
public function getId()
{
return $this->id;
}
public function setWidth($width)
{
$this->width = $width;
}
public function getWidth()
{
return $this->width;
}
public function setXCoordinate($xCoordinate)
{
$this->xCoordinate = $xCoordinate;
}
public function getXCoordinate()
{
return $this->xCoordinate;
}
public function setYCoordinate($yCoordinate)
{
$this->yCoordinate = $yCoordinate;
}
public function getYCoordinate()
{
return $this->yCoordinate;
}
}

View File

@@ -0,0 +1,192 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
class Google_Service_Drive_TeamDriveCapabilities extends Google_Model
{
public $canAddChildren;
public $canChangeCopyRequiresWriterPermissionRestriction;
public $canChangeDomainUsersOnlyRestriction;
public $canChangeTeamDriveBackground;
public $canChangeTeamMembersOnlyRestriction;
public $canComment;
public $canCopy;
public $canDeleteChildren;
public $canDeleteTeamDrive;
public $canDownload;
public $canEdit;
public $canListChildren;
public $canManageMembers;
public $canReadRevisions;
public $canRemoveChildren;
public $canRename;
public $canRenameTeamDrive;
public $canShare;
public $canTrashChildren;
public function setCanAddChildren($canAddChildren)
{
$this->canAddChildren = $canAddChildren;
}
public function getCanAddChildren()
{
return $this->canAddChildren;
}
public function setCanChangeCopyRequiresWriterPermissionRestriction($canChangeCopyRequiresWriterPermissionRestriction)
{
$this->canChangeCopyRequiresWriterPermissionRestriction = $canChangeCopyRequiresWriterPermissionRestriction;
}
public function getCanChangeCopyRequiresWriterPermissionRestriction()
{
return $this->canChangeCopyRequiresWriterPermissionRestriction;
}
public function setCanChangeDomainUsersOnlyRestriction($canChangeDomainUsersOnlyRestriction)
{
$this->canChangeDomainUsersOnlyRestriction = $canChangeDomainUsersOnlyRestriction;
}
public function getCanChangeDomainUsersOnlyRestriction()
{
return $this->canChangeDomainUsersOnlyRestriction;
}
public function setCanChangeTeamDriveBackground($canChangeTeamDriveBackground)
{
$this->canChangeTeamDriveBackground = $canChangeTeamDriveBackground;
}
public function getCanChangeTeamDriveBackground()
{
return $this->canChangeTeamDriveBackground;
}
public function setCanChangeTeamMembersOnlyRestriction($canChangeTeamMembersOnlyRestriction)
{
$this->canChangeTeamMembersOnlyRestriction = $canChangeTeamMembersOnlyRestriction;
}
public function getCanChangeTeamMembersOnlyRestriction()
{
return $this->canChangeTeamMembersOnlyRestriction;
}
public function setCanComment($canComment)
{
$this->canComment = $canComment;
}
public function getCanComment()
{
return $this->canComment;
}
public function setCanCopy($canCopy)
{
$this->canCopy = $canCopy;
}
public function getCanCopy()
{
return $this->canCopy;
}
public function setCanDeleteChildren($canDeleteChildren)
{
$this->canDeleteChildren = $canDeleteChildren;
}
public function getCanDeleteChildren()
{
return $this->canDeleteChildren;
}
public function setCanDeleteTeamDrive($canDeleteTeamDrive)
{
$this->canDeleteTeamDrive = $canDeleteTeamDrive;
}
public function getCanDeleteTeamDrive()
{
return $this->canDeleteTeamDrive;
}
public function setCanDownload($canDownload)
{
$this->canDownload = $canDownload;
}
public function getCanDownload()
{
return $this->canDownload;
}
public function setCanEdit($canEdit)
{
$this->canEdit = $canEdit;
}
public function getCanEdit()
{
return $this->canEdit;
}
public function setCanListChildren($canListChildren)
{
$this->canListChildren = $canListChildren;
}
public function getCanListChildren()
{
return $this->canListChildren;
}
public function setCanManageMembers($canManageMembers)
{
$this->canManageMembers = $canManageMembers;
}
public function getCanManageMembers()
{
return $this->canManageMembers;
}
public function setCanReadRevisions($canReadRevisions)
{
$this->canReadRevisions = $canReadRevisions;
}
public function getCanReadRevisions()
{
return $this->canReadRevisions;
}
public function setCanRemoveChildren($canRemoveChildren)
{
$this->canRemoveChildren = $canRemoveChildren;
}
public function getCanRemoveChildren()
{
return $this->canRemoveChildren;
}
public function setCanRename($canRename)
{
$this->canRename = $canRename;
}
public function getCanRename()
{
return $this->canRename;
}
public function setCanRenameTeamDrive($canRenameTeamDrive)
{
$this->canRenameTeamDrive = $canRenameTeamDrive;
}
public function getCanRenameTeamDrive()
{
return $this->canRenameTeamDrive;
}
public function setCanShare($canShare)
{
$this->canShare = $canShare;
}
public function getCanShare()
{
return $this->canShare;
}
public function setCanTrashChildren($canTrashChildren)
{
$this->canTrashChildren = $canTrashChildren;
}
public function getCanTrashChildren()
{
return $this->canTrashChildren;
}
}

View File

@@ -0,0 +1,56 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
class Google_Service_Drive_TeamDriveList extends Google_Collection
{
protected $collection_key = 'teamDrives';
public $kind;
public $nextPageToken;
protected $teamDrivesType = 'Google_Service_Drive_TeamDrive';
protected $teamDrivesDataType = 'array';
public function setKind($kind)
{
$this->kind = $kind;
}
public function getKind()
{
return $this->kind;
}
public function setNextPageToken($nextPageToken)
{
$this->nextPageToken = $nextPageToken;
}
public function getNextPageToken()
{
return $this->nextPageToken;
}
/**
* @param Google_Service_Drive_TeamDrive
*/
public function setTeamDrives($teamDrives)
{
$this->teamDrives = $teamDrives;
}
/**
* @return Google_Service_Drive_TeamDrive
*/
public function getTeamDrives()
{
return $this->teamDrives;
}
}

View File

@@ -0,0 +1,57 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
class Google_Service_Drive_TeamDriveRestrictions extends Google_Model
{
public $adminManagedRestrictions;
public $copyRequiresWriterPermission;
public $domainUsersOnly;
public $teamMembersOnly;
public function setAdminManagedRestrictions($adminManagedRestrictions)
{
$this->adminManagedRestrictions = $adminManagedRestrictions;
}
public function getAdminManagedRestrictions()
{
return $this->adminManagedRestrictions;
}
public function setCopyRequiresWriterPermission($copyRequiresWriterPermission)
{
$this->copyRequiresWriterPermission = $copyRequiresWriterPermission;
}
public function getCopyRequiresWriterPermission()
{
return $this->copyRequiresWriterPermission;
}
public function setDomainUsersOnly($domainUsersOnly)
{
$this->domainUsersOnly = $domainUsersOnly;
}
public function getDomainUsersOnly()
{
return $this->domainUsersOnly;
}
public function setTeamMembersOnly($teamMembersOnly)
{
$this->teamMembersOnly = $teamMembersOnly;
}
public function getTeamMembersOnly()
{
return $this->teamMembersOnly;
}
}

View File

@@ -0,0 +1,75 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
class Google_Service_Drive_User extends Google_Model
{
public $displayName;
public $emailAddress;
public $kind;
public $me;
public $permissionId;
public $photoLink;
public function setDisplayName($displayName)
{
$this->displayName = $displayName;
}
public function getDisplayName()
{
return $this->displayName;
}
public function setEmailAddress($emailAddress)
{
$this->emailAddress = $emailAddress;
}
public function getEmailAddress()
{
return $this->emailAddress;
}
public function setKind($kind)
{
$this->kind = $kind;
}
public function getKind()
{
return $this->kind;
}
public function setMe($me)
{
$this->me = $me;
}
public function getMe()
{
return $this->me;
}
public function setPermissionId($permissionId)
{
$this->permissionId = $permissionId;
}
public function getPermissionId()
{
return $this->permissionId;
}
public function setPhotoLink($photoLink)
{
$this->photoLink = $photoLink;
}
public function getPhotoLink()
{
return $this->photoLink;
}
}

View File

@@ -0,0 +1,18 @@
# EditorConfig is awesome: http://EditorConfig.org
# top-most EditorConfig file
root = true
charset = utf-8
# Get rid of whitespace to avoid diffs with a bunch of EOL changes
trim_trailing_whitespace = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
# PHP-Files
[*.php]
indent_style = space
indent_size = 4

View File

@@ -0,0 +1,7 @@
*~
vendor
composer.lock
# IntelliJ
.idea
*.iml

View File

@@ -0,0 +1,54 @@
<?php
/**
* This file represents the configuration for Code Sniffing PSR-2-related
* automatic checks of coding guidelines
* Install @fabpot's great php-cs-fixer tool via
*
* $ composer global require fabpot/php-cs-fixer
*
* And then simply run
*
* $ php-cs-fixer fix --config-file .php_cs
*
* inside the root directory.
*
* http://www.php-fig.org/psr/psr-2/
* http://cs.sensiolabs.org
*/
if (PHP_SAPI !== 'cli') {
die('This script supports command line usage only. Please check your command.');
}
// Define in which folders to search and which folders to exclude
// Exclude some directories that are excluded by Git anyways to speed up the sniffing
$finder = Symfony\CS\Finder\DefaultFinder::create()
->exclude('vendor')
->in(__DIR__);
// Return a Code Sniffing configuration using
// all sniffers needed for PSR-2
// and additionally:
// - Remove leading slashes in use clauses.
// - PHP single-line arrays should not have trailing comma.
// - Single-line whitespace before closing semicolon are prohibited.
// - Remove unused use statements in the PHP source code
// - Ensure Concatenation to have at least one whitespace around
// - Remove trailing whitespace at the end of blank lines.
return Symfony\CS\Config\Config::create()
->level(Symfony\CS\FixerInterface::PSR2_LEVEL)
->fixers([
'remove_leading_slash_use',
'single_array_no_trailing_comma',
'spaces_before_semicolon',
'unused_use',
'concat_with_spaces',
'whitespacy_lines',
'ordered_use',
'single_quote',
'duplicate_semicolon',
'extra_empty_lines',
'phpdoc_no_package',
'phpdoc_scalar',
'no_empty_lines_after_phpdocs'
])
->finder($finder);

View File

@@ -0,0 +1,32 @@
language: php
branches:
only: [master]
sudo: false
php:
- 5.4
- 5.5
- 5.6
- 7.0
- 7.1
- 7.2
env:
-
- COMPOSER_ARGS="--prefer-lowest"
matrix:
include:
- php: "7.2"
env: RUN_CS_FIXER=true
before_script:
- composer update $COMPOSER_ARGS
script:
- if [ "${RUN_CS_FIXER}" = "true" ]; then
vendor/bin/php-cs-fixer fix --dry-run --diff --config-file=.php_cs .;
else
vendor/bin/phpunit;
fi

View File

@@ -0,0 +1,81 @@
## 1.4.0 (09/17/2018)
### Changes
* Add support for insecure credentials (#208)
## 1.3.3 (08/27/2018)
### Changes
* Add retry and increase timeout for GCE credentials (#195)
* [Docs] Fix spelling (#204)
* Update token url (#206)
## 1.3.2 (07/23/2018)
### Changes
* Only emits a warning for gcloud credentials (#202)
## 1.3.1 (07/19/2018)
### Changes
* Added a warning for 3 legged OAuth credentials (#199)
* [Code cleanup] Removed useless else after return (#193)
## 1.3.0 (06/04/2018)
### Changes
* Fixes usage of deprecated env var for GAE Flex (#189)
* fix - guzzlehttp/psr7 dependency version definition (#190)
* Added SystemV shared memory based CacheItemPool (#191)
## 1.2.1 (24/01/2018)
### Changes
* Fixes array merging bug in Guzzle5HttpHandler (#186)
* Fixes constructor argument bug in Subscriber & Middleware (#184)
## 1.2.0 (6/12/2017)
### Changes
* Adds async method to HTTP handlers (#176)
* Misc bug fixes and improvements (#177, #175, #178)
## 1.1.0 (10/10/2017)
### Changes
* Supports additional claims in JWT tokens (#171)
* Adds makeHttpClient for creating authorized Guzzle clients (#162)
* Misc bug fixes/improvements (#168, #161, #167, #170, #143)
## 1.0.1 (31/07/2017)
### Changes
* Adds support for Firebase 5.0 (#159)
## 1.0.0 (12/06/2017)
### Changes
* Adds hashing and shortening to enforce max key length ([@bshaffer])
* Fix for better PSR-6 compliance - verifies a hit before getting the cache item ([@bshaffer])
* README fixes ([@bshaffer])
* Change authorization header key to lowercase ([@stanley-cheung])
## 0.4.0 (23/04/2015)
### Changes
* Export callback function to update auth metadata ([@stanley-cheung][])
* Adds an implementation of User Refresh Token auth ([@stanley-cheung][])
[@bshaffer]: https://github.com/bshaffer
[@stanley-cheung]: https://github.com/stanley-cheung

View File

@@ -0,0 +1,43 @@
# Contributor Code of Conduct
As contributors and maintainers of this project,
and in the interest of fostering an open and welcoming community,
we pledge to respect all people who contribute through reporting issues,
posting feature requests, updating documentation,
submitting pull requests or patches, and other activities.
We are committed to making participation in this project
a harassment-free experience for everyone,
regardless of level of experience, gender, gender identity and expression,
sexual orientation, disability, personal appearance,
body size, race, ethnicity, age, religion, or nationality.
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery
* Personal attacks
* Trolling or insulting/derogatory comments
* Public or private harassment
* Publishing other's private information,
such as physical or electronic
addresses, without explicit permission
* Other unethical or unprofessional conduct.
Project maintainers have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct.
By adopting this Code of Conduct,
project maintainers commit themselves to fairly and consistently
applying these principles to every aspect of managing this project.
Project maintainers who do not follow or enforce the Code of Conduct
may be permanently removed from the project team.
This code of conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community.
Instances of abusive, harassing, or otherwise unacceptable behavior
may be reported by opening an issue
or contacting one or more of the project maintainers.
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0,
available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/)

View File

@@ -0,0 +1,73 @@
# How to become a contributor and submit your own code
## Contributor License Agreements
We'd love to accept your sample apps and patches! Before we can take them, we
have to jump a couple of legal hurdles.
Please fill out either the individual or corporate Contributor License Agreement
(CLA).
* If you are an individual writing original source code and you're sure you
own the intellectual property, then you'll need to sign an [individual CLA]
(http://code.google.com/legal/individual-cla-v1.0.html).
* If you work for a company that wants to allow you to contribute your work,
then you'll need to sign a [corporate CLA]
(http://code.google.com/legal/corporate-cla-v1.0.html).
Follow either of the two links above to access the appropriate CLA and
instructions for how to sign and return it. Once we receive it, we'll be able to
accept your pull requests.
## Issue reporting
* Check that the issue has not already been reported.
* Check that the issue has not already been fixed in the latest code
(a.k.a. `master`).
* Be clear, concise and precise in your description of the problem.
* Open an issue with a descriptive title and a summary in grammatically correct,
complete sentences.
* Include any relevant code to the issue summary.
## Pull requests
* Read [how to properly contribute to open source projects on Github][2].
* Fork the project.
* Use a topic/feature branch to easily amend a pull request later, if necessary.
* Write [good commit messages][3].
* Use the same coding conventions as the rest of the project.
* Commit and push until you are happy with your contribution.
* Make sure to add tests for it. This is important so I don't break it
in a future version unintentionally.
* Add an entry to the [Changelog](CHANGELOG.md) accordingly. See [changelog entry format](#changelog-entry-format).
* Please try not to mess with the Rakefile, version, or history. If you want to
have your own version, or is otherwise necessary, that is fine, but please
isolate to its own commit so I can cherry-pick around it.
* Make sure the test suite is passing and the code you wrote doesn't produce
phpunit or phplint offenses.
* [Squash related commits together][5].
* Open a [pull request][4] that relates to *only* one subject with a clear title
and description in grammatically correct, complete sentences.
### Changelog entry format
Here are a few examples:
```
* ADC Support for User Refresh Tokens (@tbetbetbe[])
* [#16](https://github.com/google/google-auth-library-php/issues/16): ADC Support for User Refresh Tokens ([@tbetbetbe][])
```
* Mark it up in [Markdown syntax][6].
* The entry line should start with `* ` (an asterisk and a space).
* If the change has a related GitHub issue (e.g. a bug fix for a reported issue), put a link to the issue as `[#16](https://github.com/google/google-auth-library-php/issues/16): `.
* Describe the brief of the change. The sentence should end with a punctuation.
* At the end of the entry, add an implicit link to your GitHub user page as `([@username][])`.
* If this is your first contribution to google-auth-library-php project, add a link definition for the implicit link to the bottom of the changelog as `[@username]: https://github.com/username`.
[1]: https://github.com/google/google-auth-php-library/issues
[2]: http://gun.io/blog/how-to-github-fork-branch-and-pull-request
[3]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
[4]: https://help.github.com/articles/using-pull-requests
[5]: http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html
[6]: http://daringfireball.net/projects/markdown/syntax

View File

@@ -0,0 +1,202 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2015 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@@ -0,0 +1,203 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@@ -0,0 +1,150 @@
# Google Auth Library for PHP
<dl>
<dt>Homepage</dt><dd><a href="http://www.github.com/google/google-auth-library-php">http://www.github.com/google/google-auth-library-php</a></dd>
<dt>Authors</dt>
<dd><a href="mailto:temiola@google.com">Tim Emiola</a></dd>
<dd><a href="mailto:stanleycheung@google.com">Stanley Cheung</a></dd>
<dd><a href="mailto:betterbrent@google.com">Brent Shaffer</a></dd>
<dt>Copyright</dt><dd>Copyright © 2015 Google, Inc.</dd>
<dt>License</dt><dd>Apache 2.0</dd>
</dl>
## Description
This is Google's officially supported PHP client library for using OAuth 2.0
authorization and authentication with Google APIs.
### Installing via Composer
The recommended way to install the google auth library is through
[Composer](http://getcomposer.org).
```bash
# Install Composer
curl -sS https://getcomposer.org/installer | php
```
Next, run the Composer command to install the latest stable version:
```bash
composer.phar require google/auth
```
## Application Default Credentials
This library provides an implementation of
[application default credentials][application default credentials] for PHP.
The Application Default Credentials provide a simple way to get authorization
credentials for use in calling Google APIs.
They are best suited for cases when the call needs to have the same identity
and authorization level for the application independent of the user. This is
the recommended approach to authorize calls to Cloud APIs, particularly when
you're building an application that uses Google Compute Engine.
#### Download your Service Account Credentials JSON file
To use `Application Default Credentials`, You first need to download a set of
JSON credentials for your project. Go to **APIs & Auth** > **Credentials** in
the [Google Developers Console][developer console] and select
**Service account** from the **Add credentials** dropdown.
> This file is your *only copy* of these credentials. It should never be
> committed with your source code, and should be stored securely.
Once downloaded, store the path to this file in the
`GOOGLE_APPLICATION_CREDENTIALS` environment variable.
```php
putenv('GOOGLE_APPLICATION_CREDENTIALS=/path/to/my/credentials.json');
```
> PHP's `putenv` function is just one way to set an environment variable.
> Consider using `.htaccess` or apache configuration files as well.
#### Enable the API you want to use
Before making your API call, you must be sure the API you're calling has been
enabled. Go to **APIs & Auth** > **APIs** in the
[Google Developers Console][developer console] and enable the APIs you'd like to
call. For the example below, you must enable the `Drive API`.
#### Call the APIs
As long as you update the environment variable below to point to *your* JSON
credentials file, the following code should output a list of your Drive files.
```php
use Google\Auth\ApplicationDefaultCredentials;
use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;
// specify the path to your application credentials
putenv('GOOGLE_APPLICATION_CREDENTIALS=/path/to/my/credentials.json');
// define the scopes for your API call
$scopes = ['https://www.googleapis.com/auth/drive.readonly'];
// create middleware
$middleware = ApplicationDefaultCredentials::getMiddleware($scopes);
$stack = HandlerStack::create();
$stack->push($middleware);
// create the HTTP client
$client = new Client([
'handler' => $stack,
'base_uri' => 'https://www.googleapis.com',
'auth' => 'google_auth' // authorize all requests
]);
// make the request
$response = $client->get('drive/v2/files');
// show the result!
print_r((string) $response->getBody());
```
##### Guzzle 5 Compatibility
If you are using [Guzzle 5][Guzzle 5], replace the `create middleware` and
`create the HTTP Client` steps with the following:
```php
// create the HTTP client
$client = new Client([
'base_url' => 'https://www.googleapis.com',
'auth' => 'google_auth' // authorize all requests
]);
// create subscriber
$subscriber = ApplicationDefaultCredentials::getSubscriber($scopes);
$client->getEmitter()->attach($subscriber);
```
## License
This library is licensed under Apache 2.0. Full license text is
available in [COPYING][copying].
## Contributing
See [CONTRIBUTING][contributing].
## Support
Please
[report bugs at the project on Github](https://github.com/google/google-auth-library-php/issues). Don't
hesitate to
[ask questions](http://stackoverflow.com/questions/tagged/google-auth-library-php)
about the client or APIs on [StackOverflow](http://stackoverflow.com).
[google-apis-php-client]: https://github.com/google/google-api-php-client
[application default credentials]: https://developers.google.com/accounts/docs/application-default-credentials
[contributing]: https://github.com/google/google-auth-library-php/tree/master/CONTRIBUTING.md
[copying]: https://github.com/google/google-auth-library-php/tree/master/COPYING
[Guzzle]: https://github.com/guzzle/guzzle
[Guzzle 5]: http://docs.guzzlephp.org/en/5.3
[developer console]: https://console.developers.google.com

View File

@@ -0,0 +1,34 @@
<?php
/*
* Copyright 2014 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
function oauth2client_php_autoload($className)
{
$classPath = explode('_', $className);
if ($classPath[0] != 'Google') {
return;
}
if (count($classPath) > 3) {
// Maximum class file path depth in this project is 3.
$classPath = array_slice($classPath, 0, 3);
}
$filePath = dirname(__FILE__) . '/src/' . implode('/', $classPath) . '.php';
if (file_exists($filePath)) {
require_once $filePath;
}
}
spl_autoload_register('oauth2client_php_autoload');

View File

@@ -0,0 +1,27 @@
{
"name": "google/auth",
"type": "library",
"description": "Google Auth Library for PHP",
"keywords": ["google", "oauth2", "authentication"],
"homepage": "http://github.com/google/google-auth-library-php",
"license": "Apache-2.0",
"require": {
"php": ">=5.4",
"firebase/php-jwt": "~2.0|~3.0|~4.0|~5.0",
"guzzlehttp/guzzle": "~5.3.1|~6.0",
"guzzlehttp/psr7": "^1.2",
"psr/http-message": "^1.0",
"psr/cache": "^1.0"
},
"require-dev": {
"guzzlehttp/promises": "0.1.1|^1.3",
"friendsofphp/php-cs-fixer": "^1.11",
"phpunit/phpunit": "^4.8.36|^5.7",
"sebastian/comparator": ">=1.2.3"
},
"autoload": {
"psr-4": {
"WPvividGoogle\\Auth\\": "src"
}
}
}

View File

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="tests/bootstrap.php" colors="true">
<php>
<env name="SUPPRESS_GCLOUD_CREDS_WARNING" value="true" force="true"/>
</php>
<testsuites>
<testsuite name="google-auth-tests">
<directory suffix="Test.php">tests</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">src</directory>
<exclude>
<directory suffix="Interface.php">src/</directory>
</exclude>
</whitelist>
</filter>
</phpunit>

View File

@@ -0,0 +1,173 @@
<?php
/*
* Copyright 2015 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace WPvividGoogle\Auth;
use DomainException;
use WPvividGoogle\Auth\Credentials\AppIdentityCredentials;
use WPvividGoogle\Auth\Credentials\GCECredentials;
use WPvividGoogle\Auth\Middleware\AuthTokenMiddleware;
use WPvividGoogle\Auth\Subscriber\AuthTokenSubscriber;
use WPvividPsr\Cache\CacheItemPoolInterface;
/**
* ApplicationDefaultCredentials obtains the default credentials for
* authorizing a request to a Google service.
*
* Application Default Credentials are described here:
* https://developers.google.com/accounts/docs/application-default-credentials
*
* This class implements the search for the application default credentials as
* described in the link.
*
* It provides three factory methods:
* - #get returns the computed credentials object
* - #getSubscriber returns an AuthTokenSubscriber built from the credentials object
* - #getMiddleware returns an AuthTokenMiddleware built from the credentials object
*
* This allows it to be used as follows with GuzzleHttp\Client:
*
* 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);
*
* $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');
*/
class ApplicationDefaultCredentials
{
/**
* Obtains an AuthTokenSubscriber that uses the default FetchAuthTokenInterface
* implementation to use in this environment.
*
* If supplied, $scope is used to in creating the credentials instance if
* 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.
* @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
*
* @return AuthTokenSubscriber
*
* @throws DomainException if no implementation can be obtained.
*/
public static function getSubscriber(
$scope = null,
callable $httpHandler = null,
array $cacheConfig = null,
CacheItemPoolInterface $cache = null
) {
$creds = self::getCredentials($scope, $httpHandler, $cacheConfig, $cache);
return new AuthTokenSubscriber($creds, $httpHandler);
}
/**
* Obtains an AuthTokenMiddleware that uses the default FetchAuthTokenInterface
* implementation to use in this environment.
*
* If supplied, $scope is used to in creating the credentials instance if
* 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.
* @param callable $httpHandler callback which delivers psr7 request
* @param array $cacheConfig configuration for the cache when it's present
* @param CacheItemPoolInterface $cache
*
* @return AuthTokenMiddleware
*
* @throws DomainException if no implementation can be obtained.
*/
public static function getMiddleware(
$scope = null,
callable $httpHandler = null,
array $cacheConfig = null,
CacheItemPoolInterface $cache = null
) {
$creds = self::getCredentials($scope, $httpHandler, $cacheConfig, $cache);
return new AuthTokenMiddleware($creds, $httpHandler);
}
/**
* Obtains the default FetchAuthTokenInterface implementation to use
* in this environment.
*
* If supplied, $scope is used to in creating the credentials instance if
* 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.
* @param callable $httpHandler callback which delivers psr7 request
* @param array $cacheConfig configuration for the cache when it's present
* @param CacheItemPoolInterface $cache
*
* @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
) {
$creds = null;
$jsonKey = CredentialsLoader::fromEnv()
?: CredentialsLoader::fromWellKnownFile();
if (!is_null($jsonKey)) {
$creds = CredentialsLoader::makeCredentials($scope, $jsonKey);
} elseif (AppIdentityCredentials::onAppEngine() && !GCECredentials::onAppEngineFlexible()) {
$creds = new AppIdentityCredentials($scope);
} elseif (GCECredentials::onGce($httpHandler)) {
$creds = new GCECredentials();
}
if (is_null($creds)) {
throw new \DomainException(self::notFound());
}
if (!is_null($cache)) {
$creds = new FetchAuthTokenCache($creds, $cacheConfig, $cache);
}
return $creds;
}
private static function notFound()
{
$msg = 'Could not load the default credentials. Browse to ';
$msg .= 'https://developers.google.com';
$msg .= '/accounts/docs/application-default-credentials';
$msg .= ' for more information';
return $msg;
}
}

View File

@@ -0,0 +1,24 @@
<?php
/*
* Copyright 2016 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace WPvividGoogle\Auth\Cache;
use WPvividPsr\Cache\InvalidArgumentException as PsrInvalidArgumentException;
class InvalidArgumentException extends \InvalidArgumentException implements PsrInvalidArgumentException
{
}

View File

@@ -0,0 +1,185 @@
<?php
/*
* Copyright 2016 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace WPvividGoogle\Auth\Cache;
use WPvividPsr\Cache\CacheItemInterface;
/**
* A cache item.
*/
final class Item implements CacheItemInterface
{
/**
* @var string
*/
private $key;
/**
* @var mixed
*/
private $value;
/**
* @var \DateTime
*/
private $expiration;
/**
* @var bool
*/
private $isHit = false;
/**
* @param string $key
*/
public function __construct($key)
{
$this->key = $key;
}
/**
* {@inheritdoc}
*/
public function getKey()
{
return $this->key;
}
/**
* {@inheritdoc}
*/
public function get()
{
return $this->isHit() ? $this->value : null;
}
/**
* {@inheritdoc}
*/
public function isHit()
{
if (!$this->isHit) {
return false;
}
if ($this->expiration === null) {
return true;
}
return new \DateTime() < $this->expiration;
}
/**
* {@inheritdoc}
*/
public function set($value)
{
$this->isHit = true;
$this->value = $value;
return $this;
}
/**
* {@inheritdoc}
*/
public function expiresAt($expiration)
{
if ($this->isValidExpiration($expiration)) {
$this->expiration = $expiration;
return $this;
}
$implementationMessage = interface_exists('DateTimeInterface')
? 'implement interface DateTimeInterface'
: 'be an instance of DateTime';
$error = sprintf(
'Argument 1 passed to %s::expiresAt() must %s, %s given',
get_class($this),
$implementationMessage,
gettype($expiration)
);
$this->handleError($error);
}
/**
* {@inheritdoc}
*/
public function expiresAfter($time)
{
if (is_int($time)) {
$this->expiration = new \DateTime("now + $time seconds");
} elseif ($time instanceof \DateInterval) {
$this->expiration = (new \DateTime())->add($time);
} elseif ($time === null) {
$this->expiration = $time;
} else {
$message = 'Argument 1 passed to %s::expiresAfter() must be an ' .
'instance of DateInterval or of the type integer, %s given';
$error = sprintf($message, get_class($this), gettype($time));
$this->handleError($error);
}
return $this;
}
/**
* Handles an error.
*
* @param string $error
* @throws \TypeError
*/
private function handleError($error)
{
if (class_exists('TypeError')) {
throw new \TypeError($error);
}
trigger_error($error, E_USER_ERROR);
}
/**
* Determines if an expiration is valid based on the rules defined by PSR6.
*
* @param mixed $expiration
* @return bool
*/
private function isValidExpiration($expiration)
{
if ($expiration === null) {
return true;
}
// We test for two types here due to the fact the DateTimeInterface
// was not introduced until PHP 5.5. Checking for the DateTime type as
// well allows us to support 5.4.
if ($expiration instanceof \DateTimeInterface) {
return true;
}
if ($expiration instanceof \DateTime) {
return true;
}
return false;
}
}

View File

@@ -0,0 +1,154 @@
<?php
/*
* Copyright 2016 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace WPvividGoogle\Auth\Cache;
use WPvividPsr\Cache\CacheItemInterface;
use WPvividPsr\Cache\CacheItemPoolInterface;
/**
* Simple in-memory cache implementation.
*/
final class MemoryCacheItemPool implements CacheItemPoolInterface
{
/**
* @var CacheItemInterface[]
*/
private $items;
/**
* @var CacheItemInterface[]
*/
private $deferredItems;
/**
* {@inheritdoc}
*/
public function getItem($key)
{
return current($this->getItems([$key]));
}
/**
* {@inheritdoc}
*/
public function getItems(array $keys = [])
{
$items = [];
foreach ($keys as $key) {
$items[$key] = $this->hasItem($key) ? clone $this->items[$key] : new Item($key);
}
return $items;
}
/**
* {@inheritdoc}
*/
public function hasItem($key)
{
$this->isValidKey($key);
return isset($this->items[$key]) && $this->items[$key]->isHit();
}
/**
* {@inheritdoc}
*/
public function clear()
{
$this->items = [];
$this->deferredItems = [];
return true;
}
/**
* {@inheritdoc}
*/
public function deleteItem($key)
{
return $this->deleteItems([$key]);
}
/**
* {@inheritdoc}
*/
public function deleteItems(array $keys)
{
array_walk($keys, [$this, 'isValidKey']);
foreach ($keys as $key) {
unset($this->items[$key]);
}
return true;
}
/**
* {@inheritdoc}
*/
public function save(CacheItemInterface $item)
{
$this->items[$item->getKey()] = $item;
return true;
}
/**
* {@inheritdoc}
*/
public function saveDeferred(CacheItemInterface $item)
{
$this->deferredItems[$item->getKey()] = $item;
return true;
}
/**
* {@inheritdoc}
*/
public function commit()
{
foreach ($this->deferredItems as $item) {
$this->save($item);
}
$this->deferredItems = [];
return true;
}
/**
* Determines if the provided key is valid.
*
* @param string $key
* @return bool
* @throws InvalidArgumentException
*/
private function isValidKey($key)
{
$invalidCharacters = '{}()/\\\\@:';
if (!is_string($key) || preg_match("#[$invalidCharacters]#", $key)) {
throw new InvalidArgumentException('The provided key is not valid: ' . var_export($key, true));
}
return true;
}
}

View File

@@ -0,0 +1,231 @@
<?php
/**
* Copyright 2018 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace WPvividGoogle\Auth\Cache;
use WPvividPsr\Cache\CacheItemInterface;
use WPvividPsr\Cache\CacheItemPoolInterface;
/**
* SystemV shared memory based CacheItemPool implementation.
*
* This CacheItemPool implementation can be used among multiple processes, but
* it doesn't provide any locking mechanism. If multiple processes write to
* this ItemPool, you have to avoid race condition manually in your code.
*/
class SysVCacheItemPool implements CacheItemPoolInterface
{
const VAR_KEY = 1;
const DEFAULT_PROJ = 'A';
const DEFAULT_MEMSIZE = 10000;
const DEFAULT_PERM = 0600;
/** @var int */
private $sysvKey;
/**
* @var CacheItemInterface[]
*/
private $items;
/**
* @var CacheItemInterface[]
*/
private $deferredItems;
/**
* @var array
*/
private $options;
/**
* Save the current items.
*
* @return bool true when success, false upon failure
*/
private function saveCurrentItems()
{
$shmid = shm_attach(
$this->sysvKey,
$this->options['memsize'],
$this->options['perm']
);
if ($shmid !== false) {
$ret = shm_put_var(
$shmid,
$this->options['variableKey'],
$this->items
);
shm_detach($shmid);
return $ret;
}
return false;
}
/**
* Load the items from the shared memory.
*
* @return bool true when success, false upon failure
*/
private function loadItems()
{
$shmid = shm_attach(
$this->sysvKey,
$this->options['memsize'],
$this->options['perm']
);
if ($shmid !== false) {
$data = @shm_get_var($shmid, $this->options['variableKey']);
if (!empty($data)) {
$this->items = $data;
} else {
$this->items = [];
}
shm_detach($shmid);
return true;
}
return false;
}
/**
* 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.
*/
public function __construct($options = [])
{
if (! extension_loaded('sysvshm')) {
throw \RuntimeException(
'sysvshm extension is required to use this ItemPool');
}
$this->options = $options + [
'variableKey' => self::VAR_KEY,
'proj' => self::DEFAULT_PROJ,
'memsize' => self::DEFAULT_MEMSIZE,
'perm' => self::DEFAULT_PERM
];
$this->items = [];
$this->deferredItems = [];
$this->sysvKey = ftok(__FILE__, $this->options['proj']);
$this->loadItems();
}
/**
* {@inheritdoc}
*/
public function getItem($key)
{
$this->loadItems();
return current($this->getItems([$key]));
}
/**
* {@inheritdoc}
*/
public function getItems(array $keys = [])
{
$this->loadItems();
$items = [];
foreach ($keys as $key) {
$items[$key] = $this->hasItem($key) ?
clone $this->items[$key] :
new Item($key);
}
return $items;
}
/**
* {@inheritdoc}
*/
public function hasItem($key)
{
$this->loadItems();
return isset($this->items[$key]) && $this->items[$key]->isHit();
}
/**
* {@inheritdoc}
*/
public function clear()
{
$this->items = [];
$this->deferredItems = [];
return $this->saveCurrentItems();
}
/**
* {@inheritdoc}
*/
public function deleteItem($key)
{
return $this->deleteItems([$key]);
}
/**
* {@inheritdoc}
*/
public function deleteItems(array $keys)
{
foreach ($keys as $key) {
unset($this->items[$key]);
}
return $this->saveCurrentItems();
}
/**
* {@inheritdoc}
*/
public function save(CacheItemInterface $item)
{
$this->items[$item->getKey()] = $item;
return $this->saveCurrentItems();
}
/**
* {@inheritdoc}
*/
public function saveDeferred(CacheItemInterface $item)
{
$this->deferredItems[$item->getKey()] = $item;
return true;
}
/**
* {@inheritdoc}
*/
public function commit()
{
foreach ($this->deferredItems as $item) {
if ($this->save($item) === false) {
return false;
}
}
$this->deferredItems = [];
return true;
}
}

View File

@@ -0,0 +1,83 @@
<?php
/*
* Copyright 2015 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace WPvividGoogle\Auth;
trait CacheTrait
{
private $maxKeyLength = 64;
/**
* Gets the cached value if it is present in the cache when that is
* available.
*/
private function getCachedValue($k)
{
if (is_null($this->cache)) {
return;
}
$key = $this->getFullCacheKey($k);
if (is_null($key)) {
return;
}
$cacheItem = $this->cache->getItem($key);
if ($cacheItem->isHit()) {
return $cacheItem->get();
}
}
/**
* Saves the value in the cache when that is available.
*/
private function setCachedValue($k, $v)
{
if (is_null($this->cache)) {
return;
}
$key = $this->getFullCacheKey($k);
if (is_null($key)) {
return;
}
$cacheItem = $this->cache->getItem($key);
$cacheItem->set($v);
$cacheItem->expiresAfter($this->cacheConfig['lifetime']);
return $this->cache->save($cacheItem);
}
private function getFullCacheKey($key)
{
if (is_null($key)) {
return;
}
$key = $this->cacheConfig['prefix'] . $key;
// ensure we do not have illegal characters
$key = preg_replace('|[^a-zA-Z0-9_\.!]|', '', $key);
// Hash keys if they exceed $maxKeyLength (defaults to 64)
if ($this->maxKeyLength && strlen($key) > $this->maxKeyLength) {
$key = substr(hash('sha256', $key), 0, $this->maxKeyLength);
}
return $key;
}
}

View File

@@ -0,0 +1,159 @@
<?php
/*
* Copyright 2015 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace WPvividGoogle\Auth\Credentials;
/*
* The AppIdentityService class is automatically defined on App Engine,
* so including this dependency is not necessary, and will result in a
* PHP fatal error in the App Engine environment.
*/
use google\appengine\api\app_identity\AppIdentityService;
use WPvividGoogle\Auth\CredentialsLoader;
/**
* AppIdentityCredentials supports authorization on Google App Engine.
*
* It can be used to authorize requests using the AuthTokenMiddleware or
* AuthTokenSubscriber, but will only succeed if being run on App Engine:
*
* use Google\Auth\Credentials\AppIdentityCredentials;
* use Google\Auth\Middleware\AuthTokenMiddleware;
* use GuzzleHttp\Client;
* use GuzzleHttp\HandlerStack;
*
* $gae = new AppIdentityCredentials('https://www.googleapis.com/auth/books');
* $middleware = new AuthTokenMiddleware($gae);
* $stack = HandlerStack::create();
* $stack->push($middleware);
*
* $client = new Client([
* 'handler' => $stack,
* 'base_uri' => 'https://www.googleapis.com/books/v1',
* 'auth' => 'google_auth'
* ]);
*
* $res = $client->get('volumes?q=Henry+David+Thoreau&country=US');
*/
class AppIdentityCredentials extends CredentialsLoader
{
/**
* Result of fetchAuthToken.
*
* @array
*/
protected $lastReceivedToken;
/**
* Array of OAuth2 scopes to be requested.
*/
private $scope;
public function __construct($scope = array())
{
$this->scope = $scope;
}
/**
* Determines if this an App Engine instance, by accessing the
* SERVER_SOFTWARE environment variable (prod) or the APPENGINE_RUNTIME
* environment variable (dev).
*
* @return true if this an App Engine Instance, false otherwise
*/
public static function onAppEngine()
{
$appEngineProduction = isset($_SERVER['SERVER_SOFTWARE']) &&
0 === strpos($_SERVER['SERVER_SOFTWARE'], 'Google App Engine');
if ($appEngineProduction) {
return true;
}
$appEngineDevAppServer = isset($_SERVER['APPENGINE_RUNTIME']) &&
$_SERVER['APPENGINE_RUNTIME'] == 'php';
if ($appEngineDevAppServer) {
return true;
}
return false;
}
/**
* Implements FetchAuthTokenInterface#fetchAuthToken.
*
* Fetches the auth tokens using the AppIdentityService if available.
* As the AppIdentityService uses protobufs to fetch the access token,
* the GuzzleHttp\ClientInterface instance passed in will not be used.
*
* @param callable $httpHandler callback which delivers psr7 request
*
* @return array the auth metadata:
* array(2) {
* ["access_token"]=>
* string(3) "xyz"
* ["expiration_time"]=>
* string(10) "1444339905"
* }
*
* @throws \Exception
*/
public function fetchAuthToken(callable $httpHandler = null)
{
if (!self::onAppEngine()) {
return array();
}
if (!class_exists('google\appengine\api\app_identity\AppIdentityService')) {
throw new \Exception(
'This class must be run in App Engine, or you must include the AppIdentityService '
. 'mock class defined in tests/mocks/AppIdentityService.php'
);
}
// AppIdentityService expects an array when multiple scopes are supplied
$scope = is_array($this->scope) ? $this->scope : explode(' ', $this->scope);
$token = AppIdentityService::getAccessToken($scope);
$this->lastReceivedToken = $token;
return $token;
}
/**
* @return array|null
*/
public function getLastReceivedToken()
{
if ($this->lastReceivedToken) {
return [
'access_token' => $this->lastReceivedToken['access_token'],
'expires_at' => $this->lastReceivedToken['expiration_time'],
];
}
return null;
}
/**
* Caching is handled by the underlying AppIdentityService, return empty string
* to prevent caching.
*
* @return string
*/
public function getCacheKey()
{
return '';
}
}

View File

@@ -0,0 +1,233 @@
<?php
/*
* Copyright 2015 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace WPvividGoogle\Auth\Credentials;
use WPvividGoogle\Auth\CredentialsLoader;
use WPvividGoogle\Auth\HttpHandler\HttpHandlerFactory;
use WPvividGuzzleHttp\Exception\ClientException;
use WPvividGuzzleHttp\Exception\RequestException;
use WPvividGuzzleHttp\Exception\ServerException;
use WPvividGuzzleHttp\Psr7\Request;
/**
* GCECredentials supports authorization on Google Compute Engine.
*
* It can be used to authorize requests using the AuthTokenMiddleware, but will
* only succeed if being run on GCE:
*
* use Google\Auth\Credentials\GCECredentials;
* use Google\Auth\Middleware\AuthTokenMiddleware;
* use GuzzleHttp\Client;
* use GuzzleHttp\HandlerStack;
*
* $gce = new GCECredentials();
* $middleware = new AuthTokenMiddleware($gce);
* $stack = HandlerStack::create();
* $stack->push($middleware);
*
* $client = new Client([
* 'handler' => $stack,
* 'base_uri' => 'https://www.googleapis.com/taskqueue/v1beta2/projects/',
* 'auth' => 'google_auth'
* ]);
*
* $res = $client->get('myproject/taskqueues/myqueue');
*/
class GCECredentials extends CredentialsLoader
{
const cacheKey = 'GOOGLE_AUTH_PHP_GCE';
/**
* The metadata IP address on appengine instances.
*
* The IP is used instead of the domain 'metadata' to avoid slow responses
* when not on Compute Engine.
*/
const METADATA_IP = '169.254.169.254';
/**
* The metadata path of the default token.
*/
const TOKEN_URI_PATH = 'v1/instance/service-accounts/default/token';
/**
* The header whose presence indicates GCE presence.
*/
const FLAVOR_HEADER = 'Metadata-Flavor';
/**
* Note: the explicit `timeout` and `tries` below is a workaround. The underlying
* issue is that resolving an unknown host on some networks will take
* 20-30 seconds; making this timeout short fixes the issue, but
* could lead to false negatives in the event that we are on GCE, but
* the metadata resolution was particularly slow. The latter case is
* "unlikely" since the expected 4-nines time is about 0.5 seconds.
* This allows us to limit the total ping maximum timeout to 1.5 seconds
* for developer desktop scenarios.
*/
const MAX_COMPUTE_PING_TRIES = 3;
const COMPUTE_PING_CONNECTION_TIMEOUT_S = 0.5;
/**
* Flag used to ensure that the onGCE test is only done once;.
*
* @var bool
*/
private $hasCheckedOnGce = false;
/**
* Flag that stores the value of the onGCE check.
*
* @var bool
*/
private $isOnGce = false;
/**
* Result of fetchAuthToken.
*/
protected $lastReceivedToken;
/**
* The full uri for accessing the default token.
*
* @return string
*/
public static function getTokenUri()
{
$base = 'http://' . self::METADATA_IP . '/computeMetadata/';
return $base . self::TOKEN_URI_PATH;
}
/**
* 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
*/
public static function onAppEngineFlexible()
{
return substr(getenv('GAE_INSTANCE'), 0, 4) === 'aef-';
}
/**
* Determines if this a GCE instance, by accessing the expected metadata
* host.
* If $httpHandler is not specified a the default HttpHandler is used.
*
* @param callable $httpHandler callback which delivers psr7 request
*
* @return true if this a GCEInstance false otherwise
*/
public static function onGce(callable $httpHandler = null)
{
if (is_null($httpHandler)) {
$httpHandler = HttpHandlerFactory::build();
}
$checkUri = 'http://' . self::METADATA_IP;
for ($i = 1; $i <= self::MAX_COMPUTE_PING_TRIES; $i++) {
try {
// Comment from: oauth2client/client.py
//
// Note: the explicit `timeout` below is a workaround. The underlying
// issue is that resolving an unknown host on some networks will take
// 20-30 seconds; making this timeout short fixes the issue, but
// could lead to false negatives in the event that we are on GCE, but
// the metadata resolution was particularly slow. The latter case is
// "unlikely".
$resp = $httpHandler(
new Request('GET', $checkUri),
['timeout' => self::COMPUTE_PING_CONNECTION_TIMEOUT_S]
);
return $resp->getHeaderLine(self::FLAVOR_HEADER) == 'Google';
} catch (ClientException $e) {
} catch (ServerException $e) {
} catch (RequestException $e) {
}
$httpHandler = HttpHandlerFactory::build();
}
return false;
}
/**
* Implements FetchAuthTokenInterface#fetchAuthToken.
*
* Fetches the auth tokens from the GCE metadata host if it is available.
* If $httpHandler is not specified a the default HttpHandler is used.
*
* @param callable $httpHandler callback which delivers psr7 request
*
* @return array the response
*
* @throws \Exception
*/
public function fetchAuthToken(callable $httpHandler = null)
{
if (is_null($httpHandler)) {
$httpHandler = HttpHandlerFactory::build();
}
if (!$this->hasCheckedOnGce) {
$this->isOnGce = self::onGce($httpHandler);
}
if (!$this->isOnGce) {
return array(); // return an empty array with no access token
}
$resp = $httpHandler(
new Request(
'GET',
self::getTokenUri(),
[self::FLAVOR_HEADER => 'Google']
)
);
$body = (string)$resp->getBody();
// Assume it's JSON; if it's not throw an exception
if (null === $json = json_decode($body, true)) {
throw new \Exception('Invalid JSON response');
}
// store this so we can retrieve it later
$this->lastReceivedToken = $json;
$this->lastReceivedToken['expires_at'] = time() + $json['expires_in'];
return $json;
}
/**
* @return string
*/
public function getCacheKey()
{
return self::cacheKey;
}
/**
* @return array|null
*/
public function getLastReceivedToken()
{
if ($this->lastReceivedToken) {
return [
'access_token' => $this->lastReceivedToken['access_token'],
'expires_at' => $this->lastReceivedToken['expires_at'],
];
}
return null;
}
}

View File

@@ -0,0 +1,89 @@
<?php
/*
* Copyright 2015 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace WPvividGoogle\Auth\Credentials;
/**
* Authenticates requests using IAM credentials.
*/
class IAMCredentials
{
const SELECTOR_KEY = 'x-goog-iam-authority-selector';
const TOKEN_KEY = 'x-goog-iam-authorization-token';
/**
* @var string
*/
private $selector;
/**
* @var string
*/
private $token;
/**
* @param $selector string the IAM selector
* @param $token string the IAM token
*/
public function __construct($selector, $token)
{
if (!is_string($selector)) {
throw new \InvalidArgumentException(
'selector must be a string');
}
if (!is_string($token)) {
throw new \InvalidArgumentException(
'token must be a string');
}
$this->selector = $selector;
$this->token = $token;
}
/**
* export a callback function which updates runtime metadata.
*
* @return array updateMetadata function
*/
public function getUpdateMetadataFunc()
{
return array($this, 'updateMetadata');
}
/**
* Updates metadata with the appropriate header metadata.
*
* @param array $metadata metadata hashmap
* @param string $unusedAuthUri optional auth uri
* @param callable $httpHandler callback which delivers psr7 request
* Note: this param is unused here, only included here for
* consistency with other credentials class
*
* @return array updated metadata hashmap
*/
public function updateMetadata(
$metadata,
$unusedAuthUri = null,
callable $httpHandler = null
) {
$metadata_copy = $metadata;
$metadata_copy[self::SELECTOR_KEY] = $this->selector;
$metadata_copy[self::TOKEN_KEY] = $this->token;
return $metadata_copy;
}
}

View File

@@ -0,0 +1,68 @@
<?php
/*
* Copyright 2018 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace WPvividGoogle\Auth\Credentials;
use WPvividGoogle\Auth\FetchAuthTokenInterface;
/**
* Provides a set of credentials that will always return an empty access token.
* This is useful for APIs which do not require authentication, for local
* service emulators, and for testing.
*/
class InsecureCredentials implements FetchAuthTokenInterface
{
/**
* @var array
*/
private $token = [
'access_token' => ''
];
/**
* Fetches the auth token. In this case it returns an empty string.
*
* @param callable $httpHandler
* @return array
*/
public function fetchAuthToken(callable $httpHandler = null)
{
return $this->token;
}
/**
* Returns the cache key. In this case it returns a null value, disabling
* caching.
*
* @return string|null
*/
public function getCacheKey()
{
return null;
}
/**
* Fetches the last received token. In this case, it returns the same empty string
* auth token.
*
* @return array
*/
public function getLastReceivedToken()
{
return $this->token;
}
}

View File

@@ -0,0 +1,177 @@
<?php
/*
* Copyright 2015 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace WPvividGoogle\Auth\Credentials;
use WPvividGoogle\Auth\CredentialsLoader;
use WPvividGoogle\Auth\OAuth2;
/**
* ServiceAccountCredentials supports authorization using a Google service
* account.
*
* (cf https://developers.google.com/accounts/docs/OAuth2ServiceAccount)
*
* It's initialized using the json key file that's downloadable from developer
* console, which should contain a private_key and client_email fields that it
* uses.
*
* Use it with AuthTokenMiddleware to authorize http requests:
*
* use Google\Auth\Credentials\ServiceAccountCredentials;
* use Google\Auth\Middleware\AuthTokenMiddleware;
* use GuzzleHttp\Client;
* use GuzzleHttp\HandlerStack;
*
* $sa = new ServiceAccountCredentials(
* 'https://www.googleapis.com/auth/taskqueue',
* '/path/to/your/json/key_file.json'
* );
* $middleware = new AuthTokenMiddleware($sa);
* $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
* ]);
*
* $res = $client->get('myproject/taskqueues/myqueue');
*/
class ServiceAccountCredentials extends CredentialsLoader
{
/**
* The OAuth2 instance used to conduct authorization.
*
* @var OAuth2
*/
protected $auth;
/**
* Create a new ServiceAccountCredentials.
*
* @param string|array $scope the scope of the access request, expressed
* either as an Array or as a space-delimited String.
* @param string|array $jsonKey JSON credential file path or JSON credentials
* as an associative array
* @param string $sub an email address account to impersonate, in situations when
* the service account has been delegated domain wide access.
*/
public function __construct(
$scope,
$jsonKey,
$sub = null
) {
if (is_string($jsonKey)) {
if (!file_exists($jsonKey)) {
throw new \InvalidArgumentException('file does not exist');
}
$jsonKeyStream = file_get_contents($jsonKey);
if (!$jsonKey = json_decode($jsonKeyStream, true)) {
throw new \LogicException('invalid json for auth config');
}
}
if (!array_key_exists('client_email', $jsonKey)) {
throw new \InvalidArgumentException(
'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');
}
$this->auth = new OAuth2([
'audience' => self::TOKEN_CREDENTIAL_URI,
'issuer' => $jsonKey['client_email'],
'scope' => $scope,
'signingAlgorithm' => 'RS256',
'signingKey' => $jsonKey['private_key'],
'sub' => $sub,
'tokenCredentialUri' => self::TOKEN_CREDENTIAL_URI,
]);
}
/**
* @param callable $httpHandler
*
* @return array
*/
public function fetchAuthToken(callable $httpHandler = null)
{
return $this->auth->fetchAuthToken($httpHandler);
}
/**
* @return string
*/
public function getCacheKey()
{
$key = $this->auth->getIssuer() . ':' . $this->auth->getCacheKey();
if ($sub = $this->auth->getSub()) {
$key .= ':' . $sub;
}
return $key;
}
/**
* @return array
*/
public function getLastReceivedToken()
{
return $this->auth->getLastReceivedToken();
}
/**
* Updates metadata with the authorization token.
*
* @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(
$metadata,
$authUri = null,
callable $httpHandler = null
) {
// scope exists. use oauth implementation
$scope = $this->auth->getScope();
if (!is_null($scope)) {
return parent::updateMetadata($metadata, $authUri, $httpHandler);
}
// no scope found. create jwt with the auth uri
$credJson = array(
'private_key' => $this->auth->getSigningKey(),
'client_email' => $this->auth->getIssuer(),
);
$jwtCreds = new ServiceAccountJwtAccessCredentials($credJson);
return $jwtCreds->updateMetadata($metadata, $authUri, $httpHandler);
}
/**
* @param string $sub an email address account to impersonate, in situations when
* the service account has been delegated domain wide access.
*/
public function setSub($sub)
{
$this->auth->setSub($sub);
}
}

View File

@@ -0,0 +1,131 @@
<?php
/*
* Copyright 2015 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace WPvividGoogle\Auth\Credentials;
use WPvividGoogle\Auth\CredentialsLoader;
use WPvividGoogle\Auth\OAuth2;
/**
* Authenticates requests using Google's Service Account credentials via
* JWT Access.
*
* This class allows authorizing requests for service accounts directly
* from credentials from a json key file downloaded from the developer
* console (via 'Generate new Json Key'). It is not part of any OAuth2
* flow, rather it creates a JWT and sends that as a credential.
*/
class ServiceAccountJwtAccessCredentials extends CredentialsLoader
{
/**
* The OAuth2 instance used to conduct authorization.
*
* @var OAuth2
*/
protected $auth;
/**
* Create a new ServiceAccountJwtAccessCredentials.
*
* @param string|array $jsonKey JSON credential file path or JSON credentials
* as an associative array
*/
public function __construct($jsonKey)
{
if (is_string($jsonKey)) {
if (!file_exists($jsonKey)) {
throw new \InvalidArgumentException('file does not exist');
}
$jsonKeyStream = file_get_contents($jsonKey);
if (!$jsonKey = json_decode($jsonKeyStream, true)) {
throw new \LogicException('invalid json for auth config');
}
}
if (!array_key_exists('client_email', $jsonKey)) {
throw new \InvalidArgumentException(
'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');
}
$this->auth = new OAuth2([
'issuer' => $jsonKey['client_email'],
'sub' => $jsonKey['client_email'],
'signingAlgorithm' => 'RS256',
'signingKey' => $jsonKey['private_key'],
]);
}
/**
* Updates metadata with the authorization token.
*
* @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(
$metadata,
$authUri = null,
callable $httpHandler = null
) {
if (empty($authUri)) {
return $metadata;
}
$this->auth->setAudience($authUri);
return parent::updateMetadata($metadata, $authUri, $httpHandler);
}
/**
* Implements FetchAuthTokenInterface#fetchAuthToken.
*
* @param callable $httpHandler
*
* @return array|void
*/
public function fetchAuthToken(callable $httpHandler = null)
{
$audience = $this->auth->getAudience();
if (empty($audience)) {
return null;
}
$access_token = $this->auth->toJwt();
return array('access_token' => $access_token);
}
/**
* @return string
*/
public function getCacheKey()
{
return $this->auth->getCacheKey();
}
/**
* @return array
*/
public function getLastReceivedToken()
{
return $this->auth->getLastReceivedToken();
}
}

View File

@@ -0,0 +1,131 @@
<?php
/*
* Copyright 2015 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace WPvividGoogle\Auth\Credentials;
use WPvividGoogle\Auth\CredentialsLoader;
use WPvividGoogle\Auth\OAuth2;
/**
* Authenticates requests using User Refresh credentials.
*
* This class allows authorizing requests from user refresh tokens.
*
* This the end of the result of a 3LO flow. E.g, the end result of
* 'gcloud auth login' saves a file with these contents in well known
* location
*
* @see [Application Default Credentials](http://goo.gl/mkAHpZ)
*/
class UserRefreshCredentials extends CredentialsLoader
{
const CLOUD_SDK_CLIENT_ID =
'764086051850-6qr4p6gpi6hn506pt8ejuq83di341hur.apps.googleusercontent.com';
const SUPPRESS_CLOUD_SDK_CREDS_WARNING_ENV = 'SUPPRESS_GCLOUD_CREDS_WARNING';
/**
* The OAuth2 instance used to conduct authorization.
*
* @var OAuth2
*/
protected $auth;
/**
* Create a new UserRefreshCredentials.
*
* @param string|array $scope the scope of the access request, expressed
* either as an Array or as a space-delimited String.
* @param string|array $jsonKey JSON credential file path or JSON credentials
* as an associative array
*/
public function __construct(
$scope,
$jsonKey
) {
if (is_string($jsonKey)) {
if (!file_exists($jsonKey)) {
throw new \InvalidArgumentException('file does not exist');
}
$jsonKeyStream = file_get_contents($jsonKey);
if (!$jsonKey = json_decode($jsonKeyStream, true)) {
throw new \LogicException('invalid json for auth config');
}
}
if (!array_key_exists('client_id', $jsonKey)) {
throw new \InvalidArgumentException(
'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');
}
if (!array_key_exists('refresh_token', $jsonKey)) {
throw new \InvalidArgumentException(
'json key is missing the refresh_token field');
}
$this->auth = new OAuth2([
'clientId' => $jsonKey['client_id'],
'clientSecret' => $jsonKey['client_secret'],
'refresh_token' => $jsonKey['refresh_token'],
'scope' => $scope,
'tokenCredentialUri' => self::TOKEN_CREDENTIAL_URI,
]);
if ($jsonKey['client_id'] === self::CLOUD_SDK_CLIENT_ID
&& getenv(self::SUPPRESS_CLOUD_SDK_CREDS_WARNING_ENV) !== 'true') {
trigger_error(
'Your application has authenticated using end user credentials '
. 'from Google Cloud SDK. We recommend that most server '
. 'applications use service accounts instead. If your '
. 'application continues to use end user credentials '
. 'from Cloud SDK, you might receive a "quota exceeded" '
. 'or "API not enabled" error. For more information about '
. 'service accounts, see '
. 'https://cloud.google.com/docs/authentication/. '
. 'To disable this warning, set '
. self::SUPPRESS_CLOUD_SDK_CREDS_WARNING_ENV
. ' environment variable to "true".',
E_USER_WARNING);
}
}
/**
* @param callable $httpHandler
*
* @return array
*/
public function fetchAuthToken(callable $httpHandler = null)
{
return $this->auth->fetchAuthToken($httpHandler);
}
/**
* @return string
*/
public function getCacheKey()
{
return $this->auth->getClientId() . ':' . $this->auth->getCacheKey();
}
/**
* @return array
*/
public function getLastReceivedToken()
{
return $this->auth->getLastReceivedToken();
}
}

View File

@@ -0,0 +1,223 @@
<?php
/*
* Copyright 2015 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace WPvividGoogle\Auth;
use WPvividGoogle\Auth\Credentials\InsecureCredentials;
use WPvividGoogle\Auth\Credentials\ServiceAccountCredentials;
use WPvividGoogle\Auth\Credentials\UserRefreshCredentials;
/**
* CredentialsLoader contains the behaviour used to locate and find default
* credentials files on the file system.
*/
abstract class CredentialsLoader implements FetchAuthTokenInterface
{
const TOKEN_CREDENTIAL_URI = 'https://oauth2.googleapis.com/token';
const ENV_VAR = 'GOOGLE_APPLICATION_CREDENTIALS';
const WELL_KNOWN_PATH = 'gcloud/application_default_credentials.json';
const NON_WINDOWS_WELL_KNOWN_PATH_BASE = '.config';
const AUTH_METADATA_KEY = 'authorization';
/**
* @param string $cause
* @return string
*/
private static function unableToReadEnv($cause)
{
$msg = 'Unable to read the credential file specified by ';
$msg .= ' GOOGLE_APPLICATION_CREDENTIALS: ';
$msg .= $cause;
return $msg;
}
/**
* @return bool
*/
private static function isOnWindows()
{
return strtoupper(substr(PHP_OS, 0, 3)) === 'WIN';
}
/**
* Load a JSON key from the path specified in the environment.
*
* Load a JSON key from the path specified in the environment
* variable GOOGLE_APPLICATION_CREDENTIALS. Return null if
* GOOGLE_APPLICATION_CREDENTIALS is not specified.
*
* @return array JSON key | null
*/
public static function fromEnv()
{
$path = getenv(self::ENV_VAR);
if (empty($path)) {
return;
}
if (!file_exists($path)) {
$cause = 'file ' . $path . ' does not exist';
throw new \DomainException(self::unableToReadEnv($cause));
}
$jsonKey = file_get_contents($path);
return json_decode($jsonKey, true);
}
/**
* 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.
*
* @return array JSON key | null
*/
public static function fromWellKnownFile()
{
$rootEnv = self::isOnWindows() ? 'APPDATA' : 'HOME';
$path = [getenv($rootEnv)];
if (!self::isOnWindows()) {
$path[] = self::NON_WINDOWS_WELL_KNOWN_PATH_BASE;
}
$path[] = self::WELL_KNOWN_PATH;
$path = implode(DIRECTORY_SEPARATOR, $path);
if (!file_exists($path)) {
return;
}
$jsonKey = file_get_contents($path);
return json_decode($jsonKey, true);
}
/**
* 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.
* @param array $jsonKey the JSON credentials.
*
* @return ServiceAccountCredentials|UserRefreshCredentials
*/
public static function makeCredentials($scope, array $jsonKey)
{
if (!array_key_exists('type', $jsonKey)) {
throw new \InvalidArgumentException('json key is missing the type field');
}
if ($jsonKey['type'] == 'service_account') {
return new ServiceAccountCredentials($scope, $jsonKey);
}
if ($jsonKey['type'] == 'authorized_user') {
return new UserRefreshCredentials($scope, $jsonKey);
}
throw new \InvalidArgumentException('invalid value in the type field');
}
/**
* 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 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(
FetchAuthTokenInterface $fetcher,
array $httpClientOptions = [],
callable $httpHandler = null,
callable $tokenCallback = null
) {
$version = \WPvividGuzzleHttp\ClientInterface::VERSION;
switch ($version[0]) {
case '5':
$client = new \WPvividGuzzleHttp\Client($httpClientOptions);
$client->setDefaultOption('auth', 'google_auth');
$subscriber = new Subscriber\AuthTokenSubscriber(
$fetcher,
$httpHandler,
$tokenCallback
);
$client->getEmitter()->attach($subscriber);
return $client;
case '6':
$middleware = new Middleware\AuthTokenMiddleware(
$fetcher,
$httpHandler,
$tokenCallback
);
$stack = \WPvividGuzzleHttp\HandlerStack::create();
$stack->push($middleware);
return new \WPvividGuzzleHttp\Client([
'handler' => $stack,
'auth' => 'google_auth',
] + $httpClientOptions);
default:
throw new \Exception('Version not supported');
}
}
/**
* Create a new instance of InsecureCredentials.
*
* @return InsecureCredentials
*/
public static function makeInsecureCredentials()
{
return new InsecureCredentials();
}
/**
* export a callback function which updates runtime metadata.
*
* @return array updateMetadata function
*/
public function getUpdateMetadataFunc()
{
return array($this, 'updateMetadata');
}
/**
* Updates metadata with the authorization token.
*
* @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(
$metadata,
$authUri = null,
callable $httpHandler = null
) {
$result = $this->fetchAuthToken($httpHandler);
if (!isset($result['access_token'])) {
return $metadata;
}
$metadata_copy = $metadata;
$metadata_copy[self::AUTH_METADATA_KEY] = array('Bearer ' . $result['access_token']);
return $metadata_copy;
}
}

View File

@@ -0,0 +1,108 @@
<?php
/*
* Copyright 2010 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace WPvividGoogle\Auth;
use WPvividPsr\Cache\CacheItemPoolInterface;
/**
* A class to implement caching for any object implementing
* FetchAuthTokenInterface
*/
class FetchAuthTokenCache implements FetchAuthTokenInterface
{
use CacheTrait;
/**
* @var FetchAuthTokenInterface
*/
private $fetcher;
/**
* @var array
*/
private $cacheConfig;
/**
* @var CacheItemPoolInterface
*/
private $cache;
public function __construct(
FetchAuthTokenInterface $fetcher,
array $cacheConfig = null,
CacheItemPoolInterface $cache
) {
$this->fetcher = $fetcher;
$this->cache = $cache;
$this->cacheConfig = array_merge([
'lifetime' => 1500,
'prefix' => '',
], (array) $cacheConfig);
}
/**
* Implements FetchAuthTokenInterface#fetchAuthToken.
*
* Checks the cache for a valid auth token and fetches the auth tokens
* from the supplied fetcher.
*
* @param callable $httpHandler callback which delivers psr7 request
*
* @return array the response
*
* @throws \Exception
*/
public function fetchAuthToken(callable $httpHandler = null)
{
// Use the cached value if its available.
//
// TODO: correct caching; update the call to setCachedValue to set the expiry
// to the value returned with the auth token.
//
// TODO: correct caching; enable the cache to be cleared.
$cacheKey = $this->fetcher->getCacheKey();
$cached = $this->getCachedValue($cacheKey);
if (!empty($cached)) {
return ['access_token' => $cached];
}
$auth_token = $this->fetcher->fetchAuthToken($httpHandler);
if (isset($auth_token['access_token'])) {
$this->setCachedValue($cacheKey, $auth_token['access_token']);
}
return $auth_token;
}
/**
* @return string
*/
public function getCacheKey()
{
return $this->getFullCacheKey($this->fetcher->getCacheKey());
}
/**
* @return array|null
*/
public function getLastReceivedToken()
{
return $this->fetcher->getLastReceivedToken();
}
}

View File

@@ -0,0 +1,55 @@
<?php
/*
* Copyright 2015 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace WPvividGoogle\Auth;
/**
* An interface implemented by objects that can fetch auth tokens.
*/
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);
/**
* Obtains a key that can used to cache the results of #fetchAuthToken.
*
* If the value is empty, the auth token is not cached.
*
* @return string a key that may be used to cache the auth token.
*/
public function getCacheKey();
/**
* Returns an associative array with the token and
* expiration time.
*
* @return null|array {
* The last received access token.
*
* @var string $access_token The access token string.
* @var int $expires_at The time the token expires as a UNIX timestamp.
* }
*/
public function getLastReceivedToken();
}

View File

@@ -0,0 +1,128 @@
<?php
/**
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace WPvividGoogle\Auth\HttpHandler;
use Exception;
use WPvividGuzzleHttp\ClientInterface;
use WPvividGuzzleHttp\Message\ResponseInterface as Guzzle5ResponseInterface;
use WPvividGuzzleHttp\Promise\Promise;
use WPvividGuzzleHttp\Promise\RejectedPromise;
use WPvividGuzzleHttp\Psr7\Response;
use WPvividPsr\Http\Message\RequestInterface;
use WPvividPsr\Http\Message\ResponseInterface;
class Guzzle5HttpHandler
{
/**
* @var ClientInterface
*/
private $client;
/**
* @param ClientInterface $client
*/
public function __construct(ClientInterface $client)
{
$this->client = $client;
}
/**
* Accepts a PSR-7 Request and an array of options and returns a PSR-7 response.
*
* @param RequestInterface $request
* @param array $options
*
* @return ResponseInterface
*/
public function __invoke(RequestInterface $request, array $options = [])
{
$response = $this->client->send(
$this->createGuzzle5Request($request, $options)
);
return $this->createPsr7Response($response);
}
/**
* Accepts a PSR-7 request and an array of options and returns a PromiseInterface
*
* @param RequestInterface $request
* @param array $options
*
* @return Promise
*/
public function async(RequestInterface $request, array $options = [])
{
if (!class_exists('WPvividGuzzleHttp\Promise\Promise')) {
throw new Exception('Install guzzlehttp/promises to use async with Guzzle 5');
}
$futureResponse = $this->client->send(
$this->createGuzzle5Request(
$request,
['future' => true] + $options
)
);
$promise = new Promise(
function () use ($futureResponse) {
try {
$futureResponse->wait();
} catch (Exception $e) {
// The promise is already delivered when the exception is
// thrown, so don't rethrow it.
}
},
[$futureResponse, 'cancel']
);
$futureResponse->then([$promise, 'resolve'], [$promise, 'reject']);
return $promise->then(
function (Guzzle5ResponseInterface $response) {
// Adapt the Guzzle 5 Response to a PSR-7 Response.
return $this->createPsr7Response($response);
},
function (Exception $e) {
return new RejectedPromise($e);
}
);
}
private function createGuzzle5Request(RequestInterface $request, array $options)
{
return $this->client->createRequest(
$request->getMethod(),
$request->getUri(),
array_merge_recursive([
'headers' => $request->getHeaders(),
'body' => $request->getBody(),
], $options)
);
}
private function createPsr7Response(Guzzle5ResponseInterface $response)
{
return new Response(
$response->getStatusCode(),
$response->getHeaders() ?: [],
$response->getBody(),
$response->getProtocolVersion(),
$response->getReasonPhrase()
);
}
}

View File

@@ -0,0 +1,49 @@
<?php
namespace WPvividGoogle\Auth\HttpHandler;
use WPvividGuzzleHttp\ClientInterface;
use WPvividPsr\Http\Message\RequestInterface;
use WPvividPsr\Http\Message\ResponseInterface;
class Guzzle6HttpHandler
{
/**
* @var ClientInterface
*/
private $client;
/**
* @param ClientInterface $client
*/
public function __construct(ClientInterface $client)
{
$this->client = $client;
}
/**
* Accepts a PSR-7 request and an array of options and returns a PSR-7 response.
*
* @param RequestInterface $request
* @param array $options
*
* @return ResponseInterface
*/
public function __invoke(RequestInterface $request, array $options = [])
{
return $this->client->send($request, $options);
}
/**
* Accepts a PSR-7 request and an array of options and returns a PromiseInterface
*
* @param RequestInterface $request
* @param array $options
*
* @return \GuzzleHttp\Promise\Promise
*/
public function async(RequestInterface $request, array $options = [])
{
return $this->client->sendAsync($request, $options);
}
}

View File

@@ -0,0 +1,47 @@
<?php
/**
* Copyright 2015 Google Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace WPvividGoogle\Auth\HttpHandler;
use WPvividGuzzleHttp\Client;
use WPvividGuzzleHttp\ClientInterface;
class HttpHandlerFactory
{
/**
* Builds out a default http handler for the installed version of guzzle.
*
* @param ClientInterface $client
*
* @return Guzzle5HttpHandler|Guzzle6HttpHandler
*
* @throws \Exception
*/
public static function build(ClientInterface $client = null)
{
$version = ClientInterface::VERSION;
$client = $client ?: new Client();
switch ($version[0]) {
case '5':
return new Guzzle5HttpHandler($client);
case '6':
return new Guzzle6HttpHandler($client);
default:
throw new \Exception('Version not supported');
}
}
}

View File

@@ -0,0 +1,126 @@
<?php
/*
* Copyright 2015 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace WPvividGoogle\Auth\Middleware;
use WPvividGoogle\Auth\FetchAuthTokenInterface;
use WPvividPsr\Http\Message\RequestInterface;
/**
* AuthTokenMiddleware is a Guzzle Middleware that adds an Authorization header
* provided by an object implementing FetchAuthTokenInterface.
*
* The FetchAuthTokenInterface#fetchAuthToken is used to obtain a hash; one of
* the values value in that hash is added as the authorization header.
*
* Requests will be accessed with the authorization header:
*
* 'authorization' 'Bearer <value of auth_token>'
*/
class AuthTokenMiddleware
{
/**
* @var callback
*/
private $httpHandler;
/**
* @var FetchAuthTokenInterface
*/
private $fetcher;
/**
* @var callable
*/
private $tokenCallback;
/**
* Creates a new AuthTokenMiddleware.
*
* @param FetchAuthTokenInterface $fetcher is used to fetch the auth token
* @param callable $httpHandler (optional) callback which delivers psr7 request
* @param callable $tokenCallback (optional) function to be called when a new token is fetched.
*/
public function __construct(
FetchAuthTokenInterface $fetcher,
callable $httpHandler = null,
callable $tokenCallback = null
) {
$this->fetcher = $fetcher;
$this->httpHandler = $httpHandler;
$this->tokenCallback = $tokenCallback;
}
/**
* Updates the request with an Authorization header when auth is 'google_auth'.
*
* use Google\Auth\Middleware\AuthTokenMiddleware;
* use Google\Auth\OAuth2;
* use GuzzleHttp\Client;
* use GuzzleHttp\HandlerStack;
*
* $config = [..<oauth config param>.];
* $oauth2 = new OAuth2($config)
* $middleware = new AuthTokenMiddleware($oauth2);
* $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
* ]);
*
* $res = $client->get('myproject/taskqueues/myqueue');
*
* @param callable $handler
*
* @return \Closure
*/
public function __invoke(callable $handler)
{
return function (RequestInterface $request, array $options) use ($handler) {
// Requests using "auth"="google_auth" will be authorized.
if (!isset($options['auth']) || $options['auth'] !== 'google_auth') {
return $handler($request, $options);
}
$request = $request->withHeader('authorization', 'Bearer ' . $this->fetchToken());
return $handler($request, $options);
};
}
/**
* Call fetcher to fetch the token.
*
* @return string
*/
private function fetchToken()
{
$auth_tokens = $this->fetcher->fetchAuthToken($this->httpHandler);
if (array_key_exists('access_token', $auth_tokens)) {
// notify the callback if applicable
if ($this->tokenCallback) {
call_user_func($this->tokenCallback, $this->fetcher->getCacheKey(), $auth_tokens['access_token']);
}
return $auth_tokens['access_token'];
}
}
}

View File

@@ -0,0 +1,175 @@
<?php
/*
* Copyright 2015 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace WPvividGoogle\Auth\Middleware;
use WPvividGoogle\Auth\CacheTrait;
use WPvividPsr\Cache\CacheItemPoolInterface;
use WPvividPsr\Http\Message\RequestInterface;
/**
* ScopedAccessTokenMiddleware is a Guzzle Middleware that adds an Authorization
* header provided by a closure.
*
* The closure returns an access token, taking the scope, either a single
* string or an array of strings, as its value. If provided, a cache will be
* used to preserve the access token for a given lifetime.
*
* Requests will be accessed with the authorization header:
*
* 'authorization' 'Bearer <value of auth_token>'
*/
class ScopedAccessTokenMiddleware
{
use CacheTrait;
const DEFAULT_CACHE_LIFETIME = 1500;
/**
* @var CacheItemPoolInterface
*/
private $cache;
/**
* @var array configuration
*/
private $cacheConfig;
/**
* @var callable
*/
private $tokenFunc;
/**
* @var array|string
*/
private $scopes;
/**
* Creates a new ScopedAccessTokenMiddleware.
*
* @param callable $tokenFunc a token generator function
* @param array|string $scopes the token authentication scopes
* @param array $cacheConfig configuration for the cache when it's present
* @param CacheItemPoolInterface $cache an implementation of CacheItemPoolInterface
*/
public function __construct(
callable $tokenFunc,
$scopes,
array $cacheConfig = null,
CacheItemPoolInterface $cache = null
) {
$this->tokenFunc = $tokenFunc;
if (!(is_string($scopes) || is_array($scopes))) {
throw new \InvalidArgumentException(
'wants scope should be string or array');
}
$this->scopes = $scopes;
if (!is_null($cache)) {
$this->cache = $cache;
$this->cacheConfig = array_merge([
'lifetime' => self::DEFAULT_CACHE_LIFETIME,
'prefix' => '',
], $cacheConfig);
}
}
/**
* Updates the request with an Authorization header when auth is 'scoped'.
*
* E.g this could be used to authenticate using the AppEngine
* AppIdentityService.
*
* use google\appengine\api\app_identity\AppIdentityService;
* use Google\Auth\Middleware\ScopedAccessTokenMiddleware;
* use GuzzleHttp\Client;
* use GuzzleHttp\HandlerStack;
*
* $scope = 'https://www.googleapis.com/auth/taskqueue'
* $middleware = new ScopedAccessTokenMiddleware(
* 'AppIdentityService::getAccessToken',
* $scope,
* [ 'prefix' => 'Google\Auth\ScopedAccessToken::' ],
* $cache = new Memcache()
* );
* $stack = HandlerStack::create();
* $stack->push($middleware);
*
* $client = new Client([
* 'handler' => $stack,
* 'base_url' => 'https://www.googleapis.com/taskqueue/v1beta2/projects/',
* 'auth' => 'scoped' // authorize all requests
* ]);
*
* $res = $client->get('myproject/taskqueues/myqueue');
*
* @param callable $handler
*
* @return \Closure
*/
public function __invoke(callable $handler)
{
return function (RequestInterface $request, array $options) use ($handler) {
// Requests using "auth"="scoped" will be authorized.
if (!isset($options['auth']) || $options['auth'] !== 'scoped') {
return $handler($request, $options);
}
$request = $request->withHeader('authorization', 'Bearer ' . $this->fetchToken());
return $handler($request, $options);
};
}
/**
* @return string
*/
private function getCacheKey()
{
$key = null;
if (is_string($this->scopes)) {
$key .= $this->scopes;
} elseif (is_array($this->scopes)) {
$key .= implode(':', $this->scopes);
}
return $key;
}
/**
* Determine if token is available in the cache, if not call tokenFunc to
* fetch it.
*
* @return string
*/
private function fetchToken()
{
$cacheKey = $this->getCacheKey();
$cached = $this->getCachedValue($cacheKey);
if (!empty($cached)) {
return $cached;
}
$token = call_user_func($this->tokenFunc, $this->scopes);
$this->setCachedValue($cacheKey, $token);
return $token;
}
}

View File

@@ -0,0 +1,93 @@
<?php
/*
* Copyright 2015 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace WPvividGoogle\Auth\Middleware;
use WPvividGuzzleHttp\Psr7;
use WPvividPsr\Http\Message\RequestInterface;
/**
* SimpleMiddleware is a Guzzle Middleware that implements Google's Simple API
* access.
*
* Requests are accessed using the Simple API access developer key.
*/
class SimpleMiddleware
{
/**
* @var array
*/
private $config;
/**
* Create a new Simple plugin.
*
* The configuration array expects one option
* - key: required, otherwise InvalidArgumentException is thrown
*
* @param array $config Configuration array
*/
public function __construct(array $config)
{
if (!isset($config['key'])) {
throw new \InvalidArgumentException('requires a key to have been set');
}
$this->config = array_merge(['key' => null], $config);
}
/**
* Updates the request query with the developer key if auth is set to simple.
*
* use Google\Auth\Middleware\SimpleMiddleware;
* use GuzzleHttp\Client;
* use GuzzleHttp\HandlerStack;
*
* $my_key = 'is not the same as yours';
* $middleware = new SimpleMiddleware(['key' => $my_key]);
* $stack = HandlerStack::create();
* $stack->push($middleware);
*
* $client = new Client([
* 'handler' => $stack,
* 'base_uri' => 'https://www.googleapis.com/discovery/v1/',
* 'auth' => 'simple'
* ]);
*
* $res = $client->get('drive/v2/rest');
*
* @param callable $handler
*
* @return \Closure
*/
public function __invoke(callable $handler)
{
return function (RequestInterface $request, array $options) use ($handler) {
// Requests using "auth"="scoped" will be authorized.
if (!isset($options['auth']) || $options['auth'] !== 'simple') {
return $handler($request, $options);
}
$query = Psr7\parse_query($request->getUri()->getQuery());
$params = array_merge($query, $this->config);
$uri = $request->getUri()->withQuery(Psr7\build_query($params));
$request = $request->withUri($uri);
return $handler($request, $options);
};
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,118 @@
<?php
/*
* Copyright 2015 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
namespace WPvividGoogle\Auth\Subscriber;
use WPvividGoogle\Auth\FetchAuthTokenInterface;
use WPvividGuzzleHttp\Event\BeforeEvent;
use WPvividGuzzleHttp\Event\RequestEvents;
use WPvividGuzzleHttp\Event\SubscriberInterface;
/**
* AuthTokenSubscriber is a Guzzle Subscriber that adds an Authorization header
* provided by an object implementing FetchAuthTokenInterface.
*
* The FetchAuthTokenInterface#fetchAuthToken is used to obtain a hash; one of
* the values value in that hash is added as the authorization header.
*
* Requests will be accessed with the authorization header:
*
* 'authorization' 'Bearer <value of auth_token>'
*/
class AuthTokenSubscriber implements SubscriberInterface
{
/**
* @var callable
*/
private $httpHandler;
/**
* @var FetchAuthTokenInterface
*/
private $fetcher;
/**
* @var callable
*/
private $tokenCallback;
/**
* Creates a new AuthTokenSubscriber.
*
* @param FetchAuthTokenInterface $fetcher is used to fetch the auth token
* @param callable $httpHandler (optional) http client to fetch the token.
* @param callable $tokenCallback (optional) function to be called when a new token is fetched.
*/
public function __construct(
FetchAuthTokenInterface $fetcher,
callable $httpHandler = null,
callable $tokenCallback = null
) {
$this->fetcher = $fetcher;
$this->httpHandler = $httpHandler;
$this->tokenCallback = $tokenCallback;
}
/**
* @return array
*/
public function getEvents()
{
return ['before' => ['onBefore', RequestEvents::SIGN_REQUEST]];
}
/**
* 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;
*
* $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);
*
* $res = $client->get('myproject/taskqueues/myqueue');
*
* @param BeforeEvent $event
*/
public function onBefore(BeforeEvent $event)
{
// Requests using "auth"="google_auth" will be authorized.
$request = $event->getRequest();
if ($request->getConfig()['auth'] != 'google_auth') {
return;
}
// Fetch the auth token.
$auth_tokens = $this->fetcher->fetchAuthToken($this->httpHandler);
if (array_key_exists('access_token', $auth_tokens)) {
$request->setHeader('authorization', 'Bearer ' . $auth_tokens['access_token']);
// notify the callback if applicable
if ($this->tokenCallback) {
call_user_func($this->tokenCallback, $this->fetcher->getCacheKey(), $auth_tokens['access_token']);
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More