updated plugin WP Mail SMTP
version 2.0.0
This commit is contained in:
@ -19,7 +19,8 @@
|
||||
* Service definition for Gmail (v1).
|
||||
*
|
||||
* <p>
|
||||
* Access Gmail mailboxes including sending user email.</p>
|
||||
* The Gmail API lets you view and manage Gmail mailbox data like threads,
|
||||
* messages, and labels.</p>
|
||||
*
|
||||
* <p>
|
||||
* For more information about this service, see the API
|
||||
@ -33,6 +34,18 @@ class Google_Service_Gmail extends Google_Service
|
||||
/** Read, compose, send, and permanently delete all your email from Gmail. */
|
||||
const MAIL_GOOGLE_COM =
|
||||
"https://mail.google.com/";
|
||||
/** Manage drafts and send emails when you interact with the add-on. */
|
||||
const GMAIL_ADDONS_CURRENT_ACTION_COMPOSE =
|
||||
"https://www.googleapis.com/auth/gmail.addons.current.action.compose";
|
||||
/** View your email messages when you interact with the add-on. */
|
||||
const GMAIL_ADDONS_CURRENT_MESSAGE_ACTION =
|
||||
"https://www.googleapis.com/auth/gmail.addons.current.message.action";
|
||||
/** View your email message metadata when the add-on is running. */
|
||||
const GMAIL_ADDONS_CURRENT_MESSAGE_METADATA =
|
||||
"https://www.googleapis.com/auth/gmail.addons.current.message.metadata";
|
||||
/** View your email messages when the add-on is running. */
|
||||
const GMAIL_ADDONS_CURRENT_MESSAGE_READONLY =
|
||||
"https://www.googleapis.com/auth/gmail.addons.current.message.readonly";
|
||||
/** Manage drafts and send emails. */
|
||||
const GMAIL_COMPOSE =
|
||||
"https://www.googleapis.com/auth/gmail.compose";
|
||||
@ -85,8 +98,8 @@ class Google_Service_Gmail extends Google_Service
|
||||
{
|
||||
parent::__construct($client);
|
||||
$this->rootUrl = $rootUrl ?: 'https://www.googleapis.com/';
|
||||
$this->servicePath = 'gmail/v1/users/';
|
||||
$this->batchPath = 'batch/gmail/v1';
|
||||
$this->servicePath = '';
|
||||
$this->batchPath = 'batch';
|
||||
$this->version = 'v1';
|
||||
$this->serviceName = 'gmail';
|
||||
|
||||
@ -97,7 +110,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
array(
|
||||
'methods' => array(
|
||||
'getProfile' => array(
|
||||
'path' => '{userId}/profile',
|
||||
'path' => 'gmail/v1/users/{userId}/profile',
|
||||
'httpMethod' => 'GET',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -107,7 +120,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'stop' => array(
|
||||
'path' => '{userId}/stop',
|
||||
'path' => 'gmail/v1/users/{userId}/stop',
|
||||
'httpMethod' => 'POST',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -117,7 +130,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'watch' => array(
|
||||
'path' => '{userId}/watch',
|
||||
'path' => 'gmail/v1/users/{userId}/watch',
|
||||
'httpMethod' => 'POST',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -137,7 +150,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
array(
|
||||
'methods' => array(
|
||||
'create' => array(
|
||||
'path' => '{userId}/drafts',
|
||||
'path' => 'gmail/v1/users/{userId}/drafts',
|
||||
'httpMethod' => 'POST',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -147,7 +160,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'delete' => array(
|
||||
'path' => '{userId}/drafts/{id}',
|
||||
'path' => 'gmail/v1/users/{userId}/drafts/{id}',
|
||||
'httpMethod' => 'DELETE',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -162,7 +175,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'get' => array(
|
||||
'path' => '{userId}/drafts/{id}',
|
||||
'path' => 'gmail/v1/users/{userId}/drafts/{id}',
|
||||
'httpMethod' => 'GET',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -181,7 +194,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'list' => array(
|
||||
'path' => '{userId}/drafts',
|
||||
'path' => 'gmail/v1/users/{userId}/drafts',
|
||||
'httpMethod' => 'GET',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -193,10 +206,6 @@ class Google_Service_Gmail extends Google_Service
|
||||
'location' => 'query',
|
||||
'type' => 'boolean',
|
||||
),
|
||||
'maxResults' => array(
|
||||
'location' => 'query',
|
||||
'type' => 'integer',
|
||||
),
|
||||
'pageToken' => array(
|
||||
'location' => 'query',
|
||||
'type' => 'string',
|
||||
@ -205,9 +214,13 @@ class Google_Service_Gmail extends Google_Service
|
||||
'location' => 'query',
|
||||
'type' => 'string',
|
||||
),
|
||||
'maxResults' => array(
|
||||
'location' => 'query',
|
||||
'type' => 'integer',
|
||||
),
|
||||
),
|
||||
),'send' => array(
|
||||
'path' => '{userId}/drafts/send',
|
||||
'path' => 'gmail/v1/users/{userId}/drafts/send',
|
||||
'httpMethod' => 'POST',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -217,7 +230,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'update' => array(
|
||||
'path' => '{userId}/drafts/{id}',
|
||||
'path' => 'gmail/v1/users/{userId}/drafts/{id}',
|
||||
'httpMethod' => 'PUT',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -242,7 +255,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
array(
|
||||
'methods' => array(
|
||||
'list' => array(
|
||||
'path' => '{userId}/history',
|
||||
'path' => 'gmail/v1/users/{userId}/history',
|
||||
'httpMethod' => 'GET',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -250,10 +263,9 @@ class Google_Service_Gmail extends Google_Service
|
||||
'type' => 'string',
|
||||
'required' => true,
|
||||
),
|
||||
'historyTypes' => array(
|
||||
'pageToken' => array(
|
||||
'location' => 'query',
|
||||
'type' => 'string',
|
||||
'repeated' => true,
|
||||
),
|
||||
'labelId' => array(
|
||||
'location' => 'query',
|
||||
@ -263,9 +275,10 @@ class Google_Service_Gmail extends Google_Service
|
||||
'location' => 'query',
|
||||
'type' => 'integer',
|
||||
),
|
||||
'pageToken' => array(
|
||||
'historyTypes' => array(
|
||||
'location' => 'query',
|
||||
'type' => 'string',
|
||||
'repeated' => true,
|
||||
),
|
||||
'startHistoryId' => array(
|
||||
'location' => 'query',
|
||||
@ -283,7 +296,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
array(
|
||||
'methods' => array(
|
||||
'create' => array(
|
||||
'path' => '{userId}/labels',
|
||||
'path' => 'gmail/v1/users/{userId}/labels',
|
||||
'httpMethod' => 'POST',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -293,7 +306,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'delete' => array(
|
||||
'path' => '{userId}/labels/{id}',
|
||||
'path' => 'gmail/v1/users/{userId}/labels/{id}',
|
||||
'httpMethod' => 'DELETE',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -308,7 +321,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'get' => array(
|
||||
'path' => '{userId}/labels/{id}',
|
||||
'path' => 'gmail/v1/users/{userId}/labels/{id}',
|
||||
'httpMethod' => 'GET',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -323,7 +336,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'list' => array(
|
||||
'path' => '{userId}/labels',
|
||||
'path' => 'gmail/v1/users/{userId}/labels',
|
||||
'httpMethod' => 'GET',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -333,7 +346,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'patch' => array(
|
||||
'path' => '{userId}/labels/{id}',
|
||||
'path' => 'gmail/v1/users/{userId}/labels/{id}',
|
||||
'httpMethod' => 'PATCH',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -348,7 +361,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'update' => array(
|
||||
'path' => '{userId}/labels/{id}',
|
||||
'path' => 'gmail/v1/users/{userId}/labels/{id}',
|
||||
'httpMethod' => 'PUT',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -373,7 +386,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
array(
|
||||
'methods' => array(
|
||||
'batchDelete' => array(
|
||||
'path' => '{userId}/messages/batchDelete',
|
||||
'path' => 'gmail/v1/users/{userId}/messages/batchDelete',
|
||||
'httpMethod' => 'POST',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -383,7 +396,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'batchModify' => array(
|
||||
'path' => '{userId}/messages/batchModify',
|
||||
'path' => 'gmail/v1/users/{userId}/messages/batchModify',
|
||||
'httpMethod' => 'POST',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -393,7 +406,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'delete' => array(
|
||||
'path' => '{userId}/messages/{id}',
|
||||
'path' => 'gmail/v1/users/{userId}/messages/{id}',
|
||||
'httpMethod' => 'DELETE',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -408,7 +421,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'get' => array(
|
||||
'path' => '{userId}/messages/{id}',
|
||||
'path' => 'gmail/v1/users/{userId}/messages/{id}',
|
||||
'httpMethod' => 'GET',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -421,18 +434,18 @@ class Google_Service_Gmail extends Google_Service
|
||||
'type' => 'string',
|
||||
'required' => true,
|
||||
),
|
||||
'format' => array(
|
||||
'location' => 'query',
|
||||
'type' => 'string',
|
||||
),
|
||||
'metadataHeaders' => array(
|
||||
'location' => 'query',
|
||||
'type' => 'string',
|
||||
'repeated' => true,
|
||||
),
|
||||
'format' => array(
|
||||
'location' => 'query',
|
||||
'type' => 'string',
|
||||
),
|
||||
),
|
||||
),'import' => array(
|
||||
'path' => '{userId}/messages/import',
|
||||
'path' => 'gmail/v1/users/{userId}/messages/import',
|
||||
'httpMethod' => 'POST',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -440,7 +453,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
'type' => 'string',
|
||||
'required' => true,
|
||||
),
|
||||
'deleted' => array(
|
||||
'processForCalendar' => array(
|
||||
'location' => 'query',
|
||||
'type' => 'boolean',
|
||||
),
|
||||
@ -452,13 +465,13 @@ class Google_Service_Gmail extends Google_Service
|
||||
'location' => 'query',
|
||||
'type' => 'boolean',
|
||||
),
|
||||
'processForCalendar' => array(
|
||||
'deleted' => array(
|
||||
'location' => 'query',
|
||||
'type' => 'boolean',
|
||||
),
|
||||
),
|
||||
),'insert' => array(
|
||||
'path' => '{userId}/messages',
|
||||
'path' => 'gmail/v1/users/{userId}/messages',
|
||||
'httpMethod' => 'POST',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -466,17 +479,17 @@ class Google_Service_Gmail extends Google_Service
|
||||
'type' => 'string',
|
||||
'required' => true,
|
||||
),
|
||||
'deleted' => array(
|
||||
'location' => 'query',
|
||||
'type' => 'boolean',
|
||||
),
|
||||
'internalDateSource' => array(
|
||||
'location' => 'query',
|
||||
'type' => 'string',
|
||||
),
|
||||
'deleted' => array(
|
||||
'location' => 'query',
|
||||
'type' => 'boolean',
|
||||
),
|
||||
),
|
||||
),'list' => array(
|
||||
'path' => '{userId}/messages',
|
||||
'path' => 'gmail/v1/users/{userId}/messages',
|
||||
'httpMethod' => 'GET',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -488,26 +501,26 @@ class Google_Service_Gmail extends Google_Service
|
||||
'location' => 'query',
|
||||
'type' => 'boolean',
|
||||
),
|
||||
'pageToken' => array(
|
||||
'location' => 'query',
|
||||
'type' => 'string',
|
||||
),
|
||||
'labelIds' => array(
|
||||
'location' => 'query',
|
||||
'type' => 'string',
|
||||
'repeated' => true,
|
||||
),
|
||||
'maxResults' => array(
|
||||
'location' => 'query',
|
||||
'type' => 'integer',
|
||||
),
|
||||
'pageToken' => array(
|
||||
'location' => 'query',
|
||||
'type' => 'string',
|
||||
),
|
||||
'q' => array(
|
||||
'location' => 'query',
|
||||
'type' => 'string',
|
||||
),
|
||||
'maxResults' => array(
|
||||
'location' => 'query',
|
||||
'type' => 'integer',
|
||||
),
|
||||
),
|
||||
),'modify' => array(
|
||||
'path' => '{userId}/messages/{id}/modify',
|
||||
'path' => 'gmail/v1/users/{userId}/messages/{id}/modify',
|
||||
'httpMethod' => 'POST',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -522,7 +535,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'send' => array(
|
||||
'path' => '{userId}/messages/send',
|
||||
'path' => 'gmail/v1/users/{userId}/messages/send',
|
||||
'httpMethod' => 'POST',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -532,7 +545,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'trash' => array(
|
||||
'path' => '{userId}/messages/{id}/trash',
|
||||
'path' => 'gmail/v1/users/{userId}/messages/{id}/trash',
|
||||
'httpMethod' => 'POST',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -547,7 +560,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'untrash' => array(
|
||||
'path' => '{userId}/messages/{id}/untrash',
|
||||
'path' => 'gmail/v1/users/{userId}/messages/{id}/untrash',
|
||||
'httpMethod' => 'POST',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -572,7 +585,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
array(
|
||||
'methods' => array(
|
||||
'get' => array(
|
||||
'path' => '{userId}/messages/{messageId}/attachments/{id}',
|
||||
'path' => 'gmail/v1/users/{userId}/messages/{messageId}/attachments/{id}',
|
||||
'httpMethod' => 'GET',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -602,7 +615,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
array(
|
||||
'methods' => array(
|
||||
'getAutoForwarding' => array(
|
||||
'path' => '{userId}/settings/autoForwarding',
|
||||
'path' => 'gmail/v1/users/{userId}/settings/autoForwarding',
|
||||
'httpMethod' => 'GET',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -612,7 +625,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'getImap' => array(
|
||||
'path' => '{userId}/settings/imap',
|
||||
'path' => 'gmail/v1/users/{userId}/settings/imap',
|
||||
'httpMethod' => 'GET',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -622,7 +635,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'getLanguage' => array(
|
||||
'path' => '{userId}/settings/language',
|
||||
'path' => 'gmail/v1/users/{userId}/settings/language',
|
||||
'httpMethod' => 'GET',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -632,7 +645,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'getPop' => array(
|
||||
'path' => '{userId}/settings/pop',
|
||||
'path' => 'gmail/v1/users/{userId}/settings/pop',
|
||||
'httpMethod' => 'GET',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -642,7 +655,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'getVacation' => array(
|
||||
'path' => '{userId}/settings/vacation',
|
||||
'path' => 'gmail/v1/users/{userId}/settings/vacation',
|
||||
'httpMethod' => 'GET',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -652,7 +665,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'updateAutoForwarding' => array(
|
||||
'path' => '{userId}/settings/autoForwarding',
|
||||
'path' => 'gmail/v1/users/{userId}/settings/autoForwarding',
|
||||
'httpMethod' => 'PUT',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -662,7 +675,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'updateImap' => array(
|
||||
'path' => '{userId}/settings/imap',
|
||||
'path' => 'gmail/v1/users/{userId}/settings/imap',
|
||||
'httpMethod' => 'PUT',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -672,7 +685,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'updateLanguage' => array(
|
||||
'path' => '{userId}/settings/language',
|
||||
'path' => 'gmail/v1/users/{userId}/settings/language',
|
||||
'httpMethod' => 'PUT',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -682,7 +695,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'updatePop' => array(
|
||||
'path' => '{userId}/settings/pop',
|
||||
'path' => 'gmail/v1/users/{userId}/settings/pop',
|
||||
'httpMethod' => 'PUT',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -692,7 +705,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'updateVacation' => array(
|
||||
'path' => '{userId}/settings/vacation',
|
||||
'path' => 'gmail/v1/users/{userId}/settings/vacation',
|
||||
'httpMethod' => 'PUT',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -712,7 +725,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
array(
|
||||
'methods' => array(
|
||||
'create' => array(
|
||||
'path' => '{userId}/settings/delegates',
|
||||
'path' => 'gmail/v1/users/{userId}/settings/delegates',
|
||||
'httpMethod' => 'POST',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -722,7 +735,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'delete' => array(
|
||||
'path' => '{userId}/settings/delegates/{delegateEmail}',
|
||||
'path' => 'gmail/v1/users/{userId}/settings/delegates/{delegateEmail}',
|
||||
'httpMethod' => 'DELETE',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -737,7 +750,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'get' => array(
|
||||
'path' => '{userId}/settings/delegates/{delegateEmail}',
|
||||
'path' => 'gmail/v1/users/{userId}/settings/delegates/{delegateEmail}',
|
||||
'httpMethod' => 'GET',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -752,7 +765,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'list' => array(
|
||||
'path' => '{userId}/settings/delegates',
|
||||
'path' => 'gmail/v1/users/{userId}/settings/delegates',
|
||||
'httpMethod' => 'GET',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -772,7 +785,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
array(
|
||||
'methods' => array(
|
||||
'create' => array(
|
||||
'path' => '{userId}/settings/filters',
|
||||
'path' => 'gmail/v1/users/{userId}/settings/filters',
|
||||
'httpMethod' => 'POST',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -782,7 +795,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'delete' => array(
|
||||
'path' => '{userId}/settings/filters/{id}',
|
||||
'path' => 'gmail/v1/users/{userId}/settings/filters/{id}',
|
||||
'httpMethod' => 'DELETE',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -797,7 +810,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'get' => array(
|
||||
'path' => '{userId}/settings/filters/{id}',
|
||||
'path' => 'gmail/v1/users/{userId}/settings/filters/{id}',
|
||||
'httpMethod' => 'GET',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -812,7 +825,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'list' => array(
|
||||
'path' => '{userId}/settings/filters',
|
||||
'path' => 'gmail/v1/users/{userId}/settings/filters',
|
||||
'httpMethod' => 'GET',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -832,7 +845,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
array(
|
||||
'methods' => array(
|
||||
'create' => array(
|
||||
'path' => '{userId}/settings/forwardingAddresses',
|
||||
'path' => 'gmail/v1/users/{userId}/settings/forwardingAddresses',
|
||||
'httpMethod' => 'POST',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -842,7 +855,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'delete' => array(
|
||||
'path' => '{userId}/settings/forwardingAddresses/{forwardingEmail}',
|
||||
'path' => 'gmail/v1/users/{userId}/settings/forwardingAddresses/{forwardingEmail}',
|
||||
'httpMethod' => 'DELETE',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -857,7 +870,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'get' => array(
|
||||
'path' => '{userId}/settings/forwardingAddresses/{forwardingEmail}',
|
||||
'path' => 'gmail/v1/users/{userId}/settings/forwardingAddresses/{forwardingEmail}',
|
||||
'httpMethod' => 'GET',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -872,7 +885,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'list' => array(
|
||||
'path' => '{userId}/settings/forwardingAddresses',
|
||||
'path' => 'gmail/v1/users/{userId}/settings/forwardingAddresses',
|
||||
'httpMethod' => 'GET',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -892,7 +905,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
array(
|
||||
'methods' => array(
|
||||
'create' => array(
|
||||
'path' => '{userId}/settings/sendAs',
|
||||
'path' => 'gmail/v1/users/{userId}/settings/sendAs',
|
||||
'httpMethod' => 'POST',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -902,7 +915,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'delete' => array(
|
||||
'path' => '{userId}/settings/sendAs/{sendAsEmail}',
|
||||
'path' => 'gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}',
|
||||
'httpMethod' => 'DELETE',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -917,7 +930,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'get' => array(
|
||||
'path' => '{userId}/settings/sendAs/{sendAsEmail}',
|
||||
'path' => 'gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}',
|
||||
'httpMethod' => 'GET',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -932,7 +945,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'list' => array(
|
||||
'path' => '{userId}/settings/sendAs',
|
||||
'path' => 'gmail/v1/users/{userId}/settings/sendAs',
|
||||
'httpMethod' => 'GET',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -942,7 +955,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'patch' => array(
|
||||
'path' => '{userId}/settings/sendAs/{sendAsEmail}',
|
||||
'path' => 'gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}',
|
||||
'httpMethod' => 'PATCH',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -957,7 +970,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'update' => array(
|
||||
'path' => '{userId}/settings/sendAs/{sendAsEmail}',
|
||||
'path' => 'gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}',
|
||||
'httpMethod' => 'PUT',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -972,7 +985,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'verify' => array(
|
||||
'path' => '{userId}/settings/sendAs/{sendAsEmail}/verify',
|
||||
'path' => 'gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}/verify',
|
||||
'httpMethod' => 'POST',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -997,7 +1010,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
array(
|
||||
'methods' => array(
|
||||
'delete' => array(
|
||||
'path' => '{userId}/settings/sendAs/{sendAsEmail}/smimeInfo/{id}',
|
||||
'path' => 'gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}/smimeInfo/{id}',
|
||||
'httpMethod' => 'DELETE',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -1017,7 +1030,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'get' => array(
|
||||
'path' => '{userId}/settings/sendAs/{sendAsEmail}/smimeInfo/{id}',
|
||||
'path' => 'gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}/smimeInfo/{id}',
|
||||
'httpMethod' => 'GET',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -1037,7 +1050,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'insert' => array(
|
||||
'path' => '{userId}/settings/sendAs/{sendAsEmail}/smimeInfo',
|
||||
'path' => 'gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}/smimeInfo',
|
||||
'httpMethod' => 'POST',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -1052,7 +1065,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'list' => array(
|
||||
'path' => '{userId}/settings/sendAs/{sendAsEmail}/smimeInfo',
|
||||
'path' => 'gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}/smimeInfo',
|
||||
'httpMethod' => 'GET',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -1067,7 +1080,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'setDefault' => array(
|
||||
'path' => '{userId}/settings/sendAs/{sendAsEmail}/smimeInfo/{id}/setDefault',
|
||||
'path' => 'gmail/v1/users/{userId}/settings/sendAs/{sendAsEmail}/smimeInfo/{id}/setDefault',
|
||||
'httpMethod' => 'POST',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -1097,7 +1110,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
array(
|
||||
'methods' => array(
|
||||
'delete' => array(
|
||||
'path' => '{userId}/threads/{id}',
|
||||
'path' => 'gmail/v1/users/{userId}/threads/{id}',
|
||||
'httpMethod' => 'DELETE',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -1112,7 +1125,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'get' => array(
|
||||
'path' => '{userId}/threads/{id}',
|
||||
'path' => 'gmail/v1/users/{userId}/threads/{id}',
|
||||
'httpMethod' => 'GET',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -1125,18 +1138,18 @@ class Google_Service_Gmail extends Google_Service
|
||||
'type' => 'string',
|
||||
'required' => true,
|
||||
),
|
||||
'format' => array(
|
||||
'location' => 'query',
|
||||
'type' => 'string',
|
||||
),
|
||||
'metadataHeaders' => array(
|
||||
'location' => 'query',
|
||||
'type' => 'string',
|
||||
'repeated' => true,
|
||||
),
|
||||
'format' => array(
|
||||
'location' => 'query',
|
||||
'type' => 'string',
|
||||
),
|
||||
),
|
||||
),'list' => array(
|
||||
'path' => '{userId}/threads',
|
||||
'path' => 'gmail/v1/users/{userId}/threads',
|
||||
'httpMethod' => 'GET',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -1144,30 +1157,30 @@ class Google_Service_Gmail extends Google_Service
|
||||
'type' => 'string',
|
||||
'required' => true,
|
||||
),
|
||||
'includeSpamTrash' => array(
|
||||
'pageToken' => array(
|
||||
'location' => 'query',
|
||||
'type' => 'boolean',
|
||||
'type' => 'string',
|
||||
),
|
||||
'labelIds' => array(
|
||||
'location' => 'query',
|
||||
'type' => 'string',
|
||||
'repeated' => true,
|
||||
),
|
||||
'maxResults' => array(
|
||||
'location' => 'query',
|
||||
'type' => 'integer',
|
||||
),
|
||||
'pageToken' => array(
|
||||
'location' => 'query',
|
||||
'type' => 'string',
|
||||
),
|
||||
'q' => array(
|
||||
'location' => 'query',
|
||||
'type' => 'string',
|
||||
),
|
||||
'maxResults' => array(
|
||||
'location' => 'query',
|
||||
'type' => 'integer',
|
||||
),
|
||||
'includeSpamTrash' => array(
|
||||
'location' => 'query',
|
||||
'type' => 'boolean',
|
||||
),
|
||||
),
|
||||
),'modify' => array(
|
||||
'path' => '{userId}/threads/{id}/modify',
|
||||
'path' => 'gmail/v1/users/{userId}/threads/{id}/modify',
|
||||
'httpMethod' => 'POST',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -1182,7 +1195,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'trash' => array(
|
||||
'path' => '{userId}/threads/{id}/trash',
|
||||
'path' => 'gmail/v1/users/{userId}/threads/{id}/trash',
|
||||
'httpMethod' => 'POST',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
@ -1197,7 +1210,7 @@ class Google_Service_Gmail extends Google_Service
|
||||
),
|
||||
),
|
||||
),'untrash' => array(
|
||||
'path' => '{userId}/threads/{id}/untrash',
|
||||
'path' => 'gmail/v1/users/{userId}/threads/{id}/untrash',
|
||||
'httpMethod' => 'POST',
|
||||
'parameters' => array(
|
||||
'userId' => array(
|
||||
|
@ -81,12 +81,12 @@ class Google_Service_Gmail_Resource_UsersDrafts extends Google_Service_Resource
|
||||
*
|
||||
* @opt_param bool includeSpamTrash Include drafts from SPAM and TRASH in the
|
||||
* results.
|
||||
* @opt_param string maxResults Maximum number of drafts to return.
|
||||
* @opt_param string pageToken Page token to retrieve a specific page of results
|
||||
* in the list.
|
||||
* @opt_param string q Only return draft messages matching the specified query.
|
||||
* Supports the same query format as the Gmail search box. For example,
|
||||
* "from:someuser@example.com rfc822msgid: is:unread".
|
||||
* @opt_param string maxResults Maximum number of drafts to return.
|
||||
* @return Google_Service_Gmail_ListDraftsResponse
|
||||
*/
|
||||
public function listUsersDrafts($userId, $optParams = array())
|
||||
|
@ -34,11 +34,11 @@ class Google_Service_Gmail_Resource_UsersHistory extends Google_Service_Resource
|
||||
* used to indicate the authenticated user.
|
||||
* @param array $optParams Optional parameters.
|
||||
*
|
||||
* @opt_param string historyTypes History types to be returned by the function
|
||||
* @opt_param string labelId Only return messages with a label matching the ID.
|
||||
* @opt_param string maxResults The maximum number of history records to return.
|
||||
* @opt_param string pageToken Page token to retrieve a specific page of results
|
||||
* in the list.
|
||||
* @opt_param string labelId Only return messages with a label matching the ID.
|
||||
* @opt_param string maxResults The maximum number of history records to return.
|
||||
* @opt_param string historyTypes History types to be returned by the function
|
||||
* @opt_param string startHistoryId Required. Returns history records after the
|
||||
* specified startHistoryId. The supplied startHistoryId should be obtained from
|
||||
* the historyId of a message, thread, or previous list response. History IDs
|
||||
@ -46,7 +46,7 @@ class Google_Service_Gmail_Resource_UsersHistory extends Google_Service_Resource
|
||||
* valid IDs. Supplying an invalid or out of date startHistoryId typically
|
||||
* returns an HTTP 404 error code. A historyId is typically valid for at least a
|
||||
* week, but in some rare circumstances may be valid for only a few hours. If
|
||||
* you receive an HTTP 404 error response, your application should perform a
|
||||
* you receive an HTTP 404 error response, your application should perform a
|
||||
* full sync. If you receive no nextPageToken in the response, there are no
|
||||
* updates to retrieve and you can store the returned historyId for a future
|
||||
* request.
|
||||
|
@ -85,8 +85,7 @@ class Google_Service_Gmail_Resource_UsersLabels extends Google_Service_Resource
|
||||
return $this->call('list', array($params), "Google_Service_Gmail_ListLabelsResponse");
|
||||
}
|
||||
/**
|
||||
* Updates the specified label. This method supports patch semantics.
|
||||
* (labels.patch)
|
||||
* Patch the specified label. (labels.patch)
|
||||
*
|
||||
* @param string $userId The user's email address. The special value me can be
|
||||
* used to indicate the authenticated user.
|
||||
|
@ -26,7 +26,7 @@
|
||||
class Google_Service_Gmail_Resource_UsersMessages extends Google_Service_Resource
|
||||
{
|
||||
/**
|
||||
* Deletes many messages by message ID. Provides no guarantees that messages
|
||||
* Deletes many messages by message ID. Provides no guarantees that messages
|
||||
* were not already deleted or even existed at all. (messages.batchDelete)
|
||||
*
|
||||
* @param string $userId The user's email address. The special value me can be
|
||||
@ -56,7 +56,7 @@ class Google_Service_Gmail_Resource_UsersMessages extends Google_Service_Resourc
|
||||
}
|
||||
/**
|
||||
* Immediately and permanently deletes the specified message. This operation
|
||||
* cannot be undone. Prefer messages.trash instead. (messages.delete)
|
||||
* cannot be undone. Prefer messages.trash instead. (messages.delete)
|
||||
*
|
||||
* @param string $userId The user's email address. The special value me can be
|
||||
* used to indicate the authenticated user.
|
||||
@ -77,9 +77,9 @@ class Google_Service_Gmail_Resource_UsersMessages extends Google_Service_Resourc
|
||||
* @param string $id The ID of the message to retrieve.
|
||||
* @param array $optParams Optional parameters.
|
||||
*
|
||||
* @opt_param string format The format to return the message in.
|
||||
* @opt_param string metadataHeaders When given and format is METADATA, only
|
||||
* include headers specified.
|
||||
* @opt_param string format The format to return the message in.
|
||||
* @return Google_Service_Gmail_Message
|
||||
*/
|
||||
public function get($userId, $id, $optParams = array())
|
||||
@ -98,15 +98,15 @@ class Google_Service_Gmail_Resource_UsersMessages extends Google_Service_Resourc
|
||||
* @param Google_Service_Gmail_Message $postBody
|
||||
* @param array $optParams Optional parameters.
|
||||
*
|
||||
* @opt_param bool deleted Mark the email as permanently deleted (not TRASH) and
|
||||
* only visible in Google Vault to a Vault administrator. Only used for G Suite
|
||||
* accounts.
|
||||
* @opt_param bool processForCalendar Process calendar invites in the email and
|
||||
* add any extracted meetings to the Google Calendar for this user.
|
||||
* @opt_param string internalDateSource Source for Gmail's internal date of the
|
||||
* message.
|
||||
* @opt_param bool neverMarkSpam Ignore the Gmail spam classifier decision and
|
||||
* never mark this email as SPAM in the mailbox.
|
||||
* @opt_param bool processForCalendar Process calendar invites in the email and
|
||||
* add any extracted meetings to the Google Calendar for this user.
|
||||
* @opt_param bool deleted Mark the email as permanently deleted (not TRASH) and
|
||||
* only visible in Google Vault to a Vault administrator. Only used for G Suite
|
||||
* accounts.
|
||||
* @return Google_Service_Gmail_Message
|
||||
*/
|
||||
public function import($userId, Google_Service_Gmail_Message $postBody, $optParams = array())
|
||||
@ -125,11 +125,11 @@ class Google_Service_Gmail_Resource_UsersMessages extends Google_Service_Resourc
|
||||
* @param Google_Service_Gmail_Message $postBody
|
||||
* @param array $optParams Optional parameters.
|
||||
*
|
||||
* @opt_param string internalDateSource Source for Gmail's internal date of the
|
||||
* message.
|
||||
* @opt_param bool deleted Mark the email as permanently deleted (not TRASH) and
|
||||
* only visible in Google Vault to a Vault administrator. Only used for G Suite
|
||||
* accounts.
|
||||
* @opt_param string internalDateSource Source for Gmail's internal date of the
|
||||
* message.
|
||||
* @return Google_Service_Gmail_Message
|
||||
*/
|
||||
public function insert($userId, Google_Service_Gmail_Message $postBody, $optParams = array())
|
||||
@ -147,15 +147,16 @@ class Google_Service_Gmail_Resource_UsersMessages extends Google_Service_Resourc
|
||||
*
|
||||
* @opt_param bool includeSpamTrash Include messages from SPAM and TRASH in the
|
||||
* results.
|
||||
* @opt_param string labelIds Only return messages with labels that match all of
|
||||
* the specified label IDs.
|
||||
* @opt_param string maxResults Maximum number of messages to return.
|
||||
* @opt_param string pageToken Page token to retrieve a specific page of results
|
||||
* in the list.
|
||||
* @opt_param string labelIds Only return messages with labels that match all of
|
||||
* the specified label IDs.
|
||||
* @opt_param string q Only return messages matching the specified query.
|
||||
* Supports the same query format as the Gmail search box. For example,
|
||||
* "from:someuser@example.com rfc822msgid: is:unread". Parameter cannot be used
|
||||
* when accessing the api using the gmail.metadata scope.
|
||||
* "from:someuser@example.com rfc822msgid:somemsgid@example.com is:unread".
|
||||
* Parameter cannot be used when accessing the api using the gmail.metadata
|
||||
* scope.
|
||||
* @opt_param string maxResults Maximum number of messages to return.
|
||||
* @return Google_Service_Gmail_ListMessagesResponse
|
||||
*/
|
||||
public function listUsersMessages($userId, $optParams = array())
|
||||
|
@ -29,7 +29,7 @@ class Google_Service_Gmail_Resource_UsersSettings extends Google_Service_Resourc
|
||||
* Gets the auto-forwarding setting for the specified account.
|
||||
* (settings.getAutoForwarding)
|
||||
*
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* used to indicate the authenticated user.
|
||||
* @param array $optParams Optional parameters.
|
||||
* @return Google_Service_Gmail_AutoForwarding
|
||||
@ -43,7 +43,7 @@ class Google_Service_Gmail_Resource_UsersSettings extends Google_Service_Resourc
|
||||
/**
|
||||
* Gets IMAP settings. (settings.getImap)
|
||||
*
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* used to indicate the authenticated user.
|
||||
* @param array $optParams Optional parameters.
|
||||
* @return Google_Service_Gmail_ImapSettings
|
||||
@ -57,7 +57,7 @@ class Google_Service_Gmail_Resource_UsersSettings extends Google_Service_Resourc
|
||||
/**
|
||||
* Gets language settings. (settings.getLanguage)
|
||||
*
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* used to indicate the authenticated user.
|
||||
* @param array $optParams Optional parameters.
|
||||
* @return Google_Service_Gmail_LanguageSettings
|
||||
@ -71,7 +71,7 @@ class Google_Service_Gmail_Resource_UsersSettings extends Google_Service_Resourc
|
||||
/**
|
||||
* Gets POP settings. (settings.getPop)
|
||||
*
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* used to indicate the authenticated user.
|
||||
* @param array $optParams Optional parameters.
|
||||
* @return Google_Service_Gmail_PopSettings
|
||||
@ -85,7 +85,7 @@ class Google_Service_Gmail_Resource_UsersSettings extends Google_Service_Resourc
|
||||
/**
|
||||
* Gets vacation responder settings. (settings.getVacation)
|
||||
*
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* used to indicate the authenticated user.
|
||||
* @param array $optParams Optional parameters.
|
||||
* @return Google_Service_Gmail_VacationSettings
|
||||
@ -97,13 +97,13 @@ class Google_Service_Gmail_Resource_UsersSettings extends Google_Service_Resourc
|
||||
return $this->call('getVacation', array($params), "Google_Service_Gmail_VacationSettings");
|
||||
}
|
||||
/**
|
||||
* Updates the auto-forwarding setting for the specified account. A verified
|
||||
* Updates the auto-forwarding setting for the specified account. A verified
|
||||
* forwarding address must be specified when auto-forwarding is enabled.
|
||||
*
|
||||
* This method is only available to service account clients that have been
|
||||
* delegated domain-wide authority. (settings.updateAutoForwarding)
|
||||
*
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* used to indicate the authenticated user.
|
||||
* @param Google_Service_Gmail_AutoForwarding $postBody
|
||||
* @param array $optParams Optional parameters.
|
||||
@ -118,7 +118,7 @@ class Google_Service_Gmail_Resource_UsersSettings extends Google_Service_Resourc
|
||||
/**
|
||||
* Updates IMAP settings. (settings.updateImap)
|
||||
*
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* used to indicate the authenticated user.
|
||||
* @param Google_Service_Gmail_ImapSettings $postBody
|
||||
* @param array $optParams Optional parameters.
|
||||
@ -139,7 +139,7 @@ class Google_Service_Gmail_Resource_UsersSettings extends Google_Service_Resourc
|
||||
* Gmail but have a close variant that is, and so the variant may be chosen and
|
||||
* saved instead. (settings.updateLanguage)
|
||||
*
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* used to indicate the authenticated user.
|
||||
* @param Google_Service_Gmail_LanguageSettings $postBody
|
||||
* @param array $optParams Optional parameters.
|
||||
@ -154,7 +154,7 @@ class Google_Service_Gmail_Resource_UsersSettings extends Google_Service_Resourc
|
||||
/**
|
||||
* Updates POP settings. (settings.updatePop)
|
||||
*
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* used to indicate the authenticated user.
|
||||
* @param Google_Service_Gmail_PopSettings $postBody
|
||||
* @param array $optParams Optional parameters.
|
||||
@ -169,7 +169,7 @@ class Google_Service_Gmail_Resource_UsersSettings extends Google_Service_Resourc
|
||||
/**
|
||||
* Updates vacation responder settings. (settings.updateVacation)
|
||||
*
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* used to indicate the authenticated user.
|
||||
* @param Google_Service_Gmail_VacationSettings $postBody
|
||||
* @param array $optParams Optional parameters.
|
||||
|
@ -27,10 +27,10 @@ class Google_Service_Gmail_Resource_UsersSettingsDelegates extends Google_Servic
|
||||
{
|
||||
/**
|
||||
* Adds a delegate with its verification status set directly to accepted,
|
||||
* without sending any verification email. The delegate user must be a member of
|
||||
* the same G Suite organization as the delegator user.
|
||||
* without sending any verification email. The delegate user must be a member
|
||||
* of the same G Suite organization as the delegator user.
|
||||
*
|
||||
* Gmail imposes limtations on the number of delegates and delegators each user
|
||||
* Gmail imposes limitations on the number of delegates and delegators each user
|
||||
* in a G Suite organization can have. These limits depend on your organization,
|
||||
* but in general each user can have up to 25 delegates and up to 10 delegators.
|
||||
*
|
||||
@ -43,7 +43,7 @@ class Google_Service_Gmail_Resource_UsersSettingsDelegates extends Google_Servic
|
||||
* This method is only available to service account clients that have been
|
||||
* delegated domain-wide authority. (delegates.create)
|
||||
*
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* used to indicate the authenticated user.
|
||||
* @param Google_Service_Gmail_Delegate $postBody
|
||||
* @param array $optParams Optional parameters.
|
||||
@ -65,7 +65,7 @@ class Google_Service_Gmail_Resource_UsersSettingsDelegates extends Google_Servic
|
||||
* This method is only available to service account clients that have been
|
||||
* delegated domain-wide authority. (delegates.delete)
|
||||
*
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* used to indicate the authenticated user.
|
||||
* @param string $delegateEmail The email address of the user to be removed as a
|
||||
* delegate.
|
||||
@ -86,7 +86,7 @@ class Google_Service_Gmail_Resource_UsersSettingsDelegates extends Google_Servic
|
||||
* This method is only available to service account clients that have been
|
||||
* delegated domain-wide authority. (delegates.get)
|
||||
*
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* used to indicate the authenticated user.
|
||||
* @param string $delegateEmail The email address of the user whose delegate
|
||||
* relationship is to be retrieved.
|
||||
@ -105,7 +105,7 @@ class Google_Service_Gmail_Resource_UsersSettingsDelegates extends Google_Servic
|
||||
* This method is only available to service account clients that have been
|
||||
* delegated domain-wide authority. (delegates.listUsersSettingsDelegates)
|
||||
*
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* used to indicate the authenticated user.
|
||||
* @param array $optParams Optional parameters.
|
||||
* @return Google_Service_Gmail_ListDelegatesResponse
|
||||
|
@ -26,7 +26,7 @@
|
||||
class Google_Service_Gmail_Resource_UsersSettingsForwardingAddresses extends Google_Service_Resource
|
||||
{
|
||||
/**
|
||||
* Creates a forwarding address. If ownership verification is required, a
|
||||
* Creates a forwarding address. If ownership verification is required, a
|
||||
* message will be sent to the recipient and the resource's verification status
|
||||
* will be set to pending; otherwise, the resource will be created with
|
||||
* verification status set to accepted.
|
||||
@ -34,7 +34,7 @@ class Google_Service_Gmail_Resource_UsersSettingsForwardingAddresses extends Goo
|
||||
* This method is only available to service account clients that have been
|
||||
* delegated domain-wide authority. (forwardingAddresses.create)
|
||||
*
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* used to indicate the authenticated user.
|
||||
* @param Google_Service_Gmail_ForwardingAddress $postBody
|
||||
* @param array $optParams Optional parameters.
|
||||
@ -53,7 +53,7 @@ class Google_Service_Gmail_Resource_UsersSettingsForwardingAddresses extends Goo
|
||||
* This method is only available to service account clients that have been
|
||||
* delegated domain-wide authority. (forwardingAddresses.delete)
|
||||
*
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* used to indicate the authenticated user.
|
||||
* @param string $forwardingEmail The forwarding address to be deleted.
|
||||
* @param array $optParams Optional parameters.
|
||||
@ -67,7 +67,7 @@ class Google_Service_Gmail_Resource_UsersSettingsForwardingAddresses extends Goo
|
||||
/**
|
||||
* Gets the specified forwarding address. (forwardingAddresses.get)
|
||||
*
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* used to indicate the authenticated user.
|
||||
* @param string $forwardingEmail The forwarding address to be retrieved.
|
||||
* @param array $optParams Optional parameters.
|
||||
@ -83,7 +83,7 @@ class Google_Service_Gmail_Resource_UsersSettingsForwardingAddresses extends Goo
|
||||
* Lists the forwarding addresses for the specified account.
|
||||
* (forwardingAddresses.listUsersSettingsForwardingAddresses)
|
||||
*
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* used to indicate the authenticated user.
|
||||
* @param array $optParams Optional parameters.
|
||||
* @return Google_Service_Gmail_ListForwardingAddressesResponse
|
||||
|
@ -26,18 +26,18 @@
|
||||
class Google_Service_Gmail_Resource_UsersSettingsSendAs extends Google_Service_Resource
|
||||
{
|
||||
/**
|
||||
* Creates a custom "from" send-as alias. If an SMTP MSA is specified, Gmail
|
||||
* Creates a custom "from" send-as alias. If an SMTP MSA is specified, Gmail
|
||||
* will attempt to connect to the SMTP service to validate the configuration
|
||||
* before creating the alias. If ownership verification is required for the
|
||||
* before creating the alias. If ownership verification is required for the
|
||||
* alias, a message will be sent to the email address and the resource's
|
||||
* verification status will be set to pending; otherwise, the resource will be
|
||||
* created with verification status set to accepted. If a signature is provided,
|
||||
* Gmail will sanitize the HTML before saving it with the alias.
|
||||
* created with verification status set to accepted. If a signature is
|
||||
* provided, Gmail will sanitize the HTML before saving it with the alias.
|
||||
*
|
||||
* This method is only available to service account clients that have been
|
||||
* delegated domain-wide authority. (sendAs.create)
|
||||
*
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* used to indicate the authenticated user.
|
||||
* @param Google_Service_Gmail_SendAs $postBody
|
||||
* @param array $optParams Optional parameters.
|
||||
@ -50,13 +50,13 @@ class Google_Service_Gmail_Resource_UsersSettingsSendAs extends Google_Service_R
|
||||
return $this->call('create', array($params), "Google_Service_Gmail_SendAs");
|
||||
}
|
||||
/**
|
||||
* Deletes the specified send-as alias. Revokes any verification that may have
|
||||
* Deletes the specified send-as alias. Revokes any verification that may have
|
||||
* been required for using it.
|
||||
*
|
||||
* This method is only available to service account clients that have been
|
||||
* delegated domain-wide authority. (sendAs.delete)
|
||||
*
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* used to indicate the authenticated user.
|
||||
* @param string $sendAsEmail The send-as alias to be deleted.
|
||||
* @param array $optParams Optional parameters.
|
||||
@ -68,10 +68,10 @@ class Google_Service_Gmail_Resource_UsersSettingsSendAs extends Google_Service_R
|
||||
return $this->call('delete', array($params));
|
||||
}
|
||||
/**
|
||||
* Gets the specified send-as alias. Fails with an HTTP 404 error if the
|
||||
* Gets the specified send-as alias. Fails with an HTTP 404 error if the
|
||||
* specified address is not a member of the collection. (sendAs.get)
|
||||
*
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* used to indicate the authenticated user.
|
||||
* @param string $sendAsEmail The send-as alias to be retrieved.
|
||||
* @param array $optParams Optional parameters.
|
||||
@ -84,11 +84,11 @@ class Google_Service_Gmail_Resource_UsersSettingsSendAs extends Google_Service_R
|
||||
return $this->call('get', array($params), "Google_Service_Gmail_SendAs");
|
||||
}
|
||||
/**
|
||||
* Lists the send-as aliases for the specified account. The result includes the
|
||||
* Lists the send-as aliases for the specified account. The result includes the
|
||||
* primary send-as address associated with the account as well as any custom
|
||||
* "from" aliases. (sendAs.listUsersSettingsSendAs)
|
||||
*
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* used to indicate the authenticated user.
|
||||
* @param array $optParams Optional parameters.
|
||||
* @return Google_Service_Gmail_ListSendAsResponse
|
||||
@ -100,14 +100,9 @@ class Google_Service_Gmail_Resource_UsersSettingsSendAs extends Google_Service_R
|
||||
return $this->call('list', array($params), "Google_Service_Gmail_ListSendAsResponse");
|
||||
}
|
||||
/**
|
||||
* Updates a send-as alias. If a signature is provided, Gmail will sanitize the
|
||||
* HTML before saving it with the alias.
|
||||
* Patch the specified send-as alias. (sendAs.patch)
|
||||
*
|
||||
* Addresses other than the primary address for the account can only be updated
|
||||
* by service account clients that have been delegated domain-wide authority.
|
||||
* This method supports patch semantics. (sendAs.patch)
|
||||
*
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* used to indicate the authenticated user.
|
||||
* @param string $sendAsEmail The send-as alias to be updated.
|
||||
* @param Google_Service_Gmail_SendAs $postBody
|
||||
@ -121,14 +116,14 @@ class Google_Service_Gmail_Resource_UsersSettingsSendAs extends Google_Service_R
|
||||
return $this->call('patch', array($params), "Google_Service_Gmail_SendAs");
|
||||
}
|
||||
/**
|
||||
* Updates a send-as alias. If a signature is provided, Gmail will sanitize the
|
||||
* Updates a send-as alias. If a signature is provided, Gmail will sanitize the
|
||||
* HTML before saving it with the alias.
|
||||
*
|
||||
* Addresses other than the primary address for the account can only be updated
|
||||
* by service account clients that have been delegated domain-wide authority.
|
||||
* (sendAs.update)
|
||||
*
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* used to indicate the authenticated user.
|
||||
* @param string $sendAsEmail The send-as alias to be updated.
|
||||
* @param Google_Service_Gmail_SendAs $postBody
|
||||
@ -148,7 +143,7 @@ class Google_Service_Gmail_Resource_UsersSettingsSendAs extends Google_Service_R
|
||||
* This method is only available to service account clients that have been
|
||||
* delegated domain-wide authority. (sendAs.verify)
|
||||
*
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* @param string $userId User's email address. The special value "me" can be
|
||||
* used to indicate the authenticated user.
|
||||
* @param string $sendAsEmail The send-as alias to be verified.
|
||||
* @param array $optParams Optional parameters.
|
||||
|
@ -48,9 +48,9 @@ class Google_Service_Gmail_Resource_UsersThreads extends Google_Service_Resource
|
||||
* @param string $id The ID of the thread to retrieve.
|
||||
* @param array $optParams Optional parameters.
|
||||
*
|
||||
* @opt_param string format The format to return the messages in.
|
||||
* @opt_param string metadataHeaders When given and format is METADATA, only
|
||||
* include headers specified.
|
||||
* @opt_param string format The format to return the messages in.
|
||||
* @return Google_Service_Gmail_Thread
|
||||
*/
|
||||
public function get($userId, $id, $optParams = array())
|
||||
@ -66,17 +66,17 @@ class Google_Service_Gmail_Resource_UsersThreads extends Google_Service_Resource
|
||||
* used to indicate the authenticated user.
|
||||
* @param array $optParams Optional parameters.
|
||||
*
|
||||
* @opt_param bool includeSpamTrash Include threads from SPAM and TRASH in the
|
||||
* results.
|
||||
* @opt_param string labelIds Only return threads with labels that match all of
|
||||
* the specified label IDs.
|
||||
* @opt_param string maxResults Maximum number of threads to return.
|
||||
* @opt_param string pageToken Page token to retrieve a specific page of results
|
||||
* in the list.
|
||||
* @opt_param string labelIds Only return threads with labels that match all of
|
||||
* the specified label IDs.
|
||||
* @opt_param string q Only return threads matching the specified query.
|
||||
* Supports the same query format as the Gmail search box. For example,
|
||||
* "from:someuser@example.com rfc822msgid: is:unread". Parameter cannot be used
|
||||
* when accessing the api using the gmail.metadata scope.
|
||||
* @opt_param string maxResults Maximum number of threads to return.
|
||||
* @opt_param bool includeSpamTrash Include threads from SPAM and TRASH in the
|
||||
* results.
|
||||
* @return Google_Service_Gmail_ListThreadsResponse
|
||||
*/
|
||||
public function listUsersThreads($userId, $optParams = array())
|
||||
|
@ -38,7 +38,7 @@ use Monolog\Handler\SyslogHandler as MonologSyslogHandler;
|
||||
*/
|
||||
class Google_Client
|
||||
{
|
||||
const LIBVER = "2.2.3";
|
||||
const LIBVER = "2.4.1";
|
||||
const USER_AGENT_SUFFIX = "google-api-php-client/";
|
||||
const OAUTH2_REVOKE_URI = 'https://oauth2.googleapis.com/revoke';
|
||||
const OAUTH2_TOKEN_URI = 'https://oauth2.googleapis.com/token';
|
||||
@ -142,6 +142,10 @@ class Google_Client
|
||||
// Service class used in Google_Client::verifyIdToken.
|
||||
// Explicitly pass this in to avoid setting JWT::$leeway
|
||||
'jwt' => null,
|
||||
|
||||
// Setting api_format_v2 will return more detailed error messages
|
||||
// from certain APIs.
|
||||
'api_format_v2' => false
|
||||
],
|
||||
$config
|
||||
);
|
||||
@ -412,6 +416,17 @@ class Google_Client
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the access token used for requests.
|
||||
*
|
||||
* Note that at the time requests are sent, tokens are cached. A token will be
|
||||
* cached for each combination of service and authentication scopes. If a
|
||||
* cache pool is not provided, creating a new instance of the client will
|
||||
* allow modification of access tokens. If a persistent cache pool is
|
||||
* provided, in order to change the access token, you must clear the cached
|
||||
* token by calling `$client->getCache()->clear()`. (Use caution in this case,
|
||||
* as calling `clear()` will remove all cache items, including any items not
|
||||
* related to Google API PHP Client.)
|
||||
*
|
||||
* @param string|array $token
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
@ -789,12 +804,31 @@ class Google_Client
|
||||
*/
|
||||
public function execute(RequestInterface $request, $expectedClass = null)
|
||||
{
|
||||
$request = $request->withHeader(
|
||||
'User-Agent',
|
||||
$this->config['application_name']
|
||||
. " " . self::USER_AGENT_SUFFIX
|
||||
. $this->getLibraryVersion()
|
||||
);
|
||||
$request = $request
|
||||
->withHeader(
|
||||
'User-Agent',
|
||||
sprintf(
|
||||
'%s %s%s',
|
||||
$this->config['application_name'],
|
||||
self::USER_AGENT_SUFFIX,
|
||||
$this->getLibraryVersion()
|
||||
)
|
||||
)
|
||||
->withHeader(
|
||||
'x-goog-api-client',
|
||||
sprintf(
|
||||
'gl-php/%s gdcl/%s',
|
||||
phpversion(),
|
||||
$this->getLibraryVersion()
|
||||
)
|
||||
);
|
||||
|
||||
if ($this->config['api_format_v2']) {
|
||||
$request = $request->withHeader(
|
||||
'X-GOOG-API-FORMAT-VERSION',
|
||||
2
|
||||
);
|
||||
}
|
||||
|
||||
// call the authorize method
|
||||
// this is where most of the grunt work is done
|
||||
@ -1056,6 +1090,18 @@ class Google_Client
|
||||
return $this->http;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the API format version.
|
||||
*
|
||||
* `true` will use V2, which may return more useful error messages.
|
||||
*
|
||||
* @param bool $value
|
||||
*/
|
||||
public function setApiFormatV2($value)
|
||||
{
|
||||
$this->config['api_format_v2'] = (bool) $value;
|
||||
}
|
||||
|
||||
protected function createDefaultHttpClient()
|
||||
{
|
||||
$options = ['exceptions' => false];
|
||||
|
@ -67,9 +67,11 @@ class Google_Http_MediaFileUpload
|
||||
private $httpResultCode;
|
||||
|
||||
/**
|
||||
* @param $mimeType string
|
||||
* @param $data string The bytes you want to upload.
|
||||
* @param $resumable bool
|
||||
* @param Google_Client $client
|
||||
* @param RequestInterface $request
|
||||
* @param string $mimeType
|
||||
* @param string $data The bytes you want to upload.
|
||||
* @param bool $resumable
|
||||
* @param bool $chunkSize File will be uploaded in chunks of this many bytes.
|
||||
* only used if resumable=True
|
||||
*/
|
||||
|
@ -294,7 +294,7 @@ class Google_Service_Resource
|
||||
}
|
||||
|
||||
if (count($queryVars)) {
|
||||
$requestUrl .= '?' . implode($queryVars, '&');
|
||||
$requestUrl .= '?' . implode('&', $queryVars);
|
||||
}
|
||||
|
||||
return $requestUrl;
|
||||
|
@ -17,6 +17,8 @@
|
||||
|
||||
namespace Google\Auth;
|
||||
|
||||
use DateTime;
|
||||
use Exception;
|
||||
use Firebase\JWT\ExpiredException;
|
||||
use Firebase\JWT\JWT;
|
||||
use Firebase\JWT\SignatureInvalidException;
|
||||
@ -25,9 +27,16 @@ use Google\Auth\HttpHandler\HttpClientCache;
|
||||
use Google\Auth\HttpHandler\HttpHandlerFactory;
|
||||
use GuzzleHttp\Psr7;
|
||||
use GuzzleHttp\Psr7\Request;
|
||||
use InvalidArgumentException;
|
||||
use phpseclib\Crypt\RSA;
|
||||
use phpseclib\Math\BigInteger;
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use RuntimeException;
|
||||
use SimpleJWT\InvalidTokenException;
|
||||
use SimpleJWT\JWT as SimpleJWT;
|
||||
use SimpleJWT\Keys\KeyFactory;
|
||||
use SimpleJWT\Keys\KeySet;
|
||||
use UnexpectedValueException;
|
||||
|
||||
/**
|
||||
* Wrapper around Google Access Tokens which provides convenience functions.
|
||||
@ -37,6 +46,8 @@ use Psr\Cache\CacheItemPoolInterface;
|
||||
class AccessToken
|
||||
{
|
||||
const FEDERATED_SIGNON_CERT_URL = 'https://www.googleapis.com/oauth2/v3/certs';
|
||||
const IAP_CERT_URL = 'https://www.gstatic.com/iap/verify/public_key-jwk';
|
||||
const IAP_ISSUER = 'https://cloud.google.com/iap';
|
||||
const OAUTH2_ISSUER = 'accounts.google.com';
|
||||
const OAUTH2_ISSUER_HTTPS = 'https://accounts.google.com';
|
||||
const OAUTH2_REVOKE_URI = 'https://oauth2.googleapis.com/revoke';
|
||||
@ -59,19 +70,9 @@ class AccessToken
|
||||
callable $httpHandler = null,
|
||||
CacheItemPoolInterface $cache = null
|
||||
) {
|
||||
// @codeCoverageIgnoreStart
|
||||
if (!class_exists('phpseclib\Crypt\RSA')) {
|
||||
throw new \RuntimeException('Please require phpseclib/phpseclib v2 to use this utility.');
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
||||
$this->httpHandler = $httpHandler
|
||||
?: HttpHandlerFactory::build(HttpClientCache::getHttpClient());
|
||||
$this->cache = $cache ?: new MemoryCacheItemPool();
|
||||
$this->configureJwtService();
|
||||
|
||||
// set phpseclib constants if applicable
|
||||
$this->setPhpsecConstants();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -85,87 +86,215 @@ class AccessToken
|
||||
* Configuration options.
|
||||
*
|
||||
* @type string $audience The indended recipient of the token.
|
||||
* @type string $issuer The intended issuer of the token.
|
||||
* @type string $certsLocation The location (remote or local) from which
|
||||
* to retrieve certificates, if not cached. This value should only be
|
||||
* provided in limited circumstances in which you are sure of the
|
||||
* behavior.
|
||||
* @type string $cacheKey The cache key of the cached certs. Defaults to
|
||||
* the sha1 of $certsLocation if provided, otherwise is set to
|
||||
* "federated_signon_certs_v3".
|
||||
* @type bool $throwException Whether the function should throw an
|
||||
* exception if the verification fails. This is useful for
|
||||
* determining the reason verification failed.
|
||||
* }
|
||||
* @return array|bool the token payload, if successful, or false if not.
|
||||
* @throws \InvalidArgumentException If certs could not be retrieved from a local file.
|
||||
* @throws \InvalidArgumentException If received certs are in an invalid format.
|
||||
* @throws \RuntimeException If certs could not be retrieved from a remote location.
|
||||
* @throws InvalidArgumentException If certs could not be retrieved from a local file.
|
||||
* @throws InvalidArgumentException If received certs are in an invalid format.
|
||||
* @throws InvalidArgumentException If the cert alg is not supported.
|
||||
* @throws RuntimeException If certs could not be retrieved from a remote location.
|
||||
* @throws UnexpectedValueException If the token issuer does not match.
|
||||
* @throws UnexpectedValueException If the token audience does not match.
|
||||
*/
|
||||
public function verify($token, array $options = [])
|
||||
{
|
||||
$audience = isset($options['audience'])
|
||||
? $options['audience']
|
||||
: null;
|
||||
$issuer = isset($options['issuer'])
|
||||
? $options['issuer']
|
||||
: null;
|
||||
$certsLocation = isset($options['certsLocation'])
|
||||
? $options['certsLocation']
|
||||
: self::FEDERATED_SIGNON_CERT_URL;
|
||||
|
||||
unset($options['audience'], $options['certsLocation']);
|
||||
$cacheKey = isset($options['cacheKey'])
|
||||
? $options['cacheKey']
|
||||
: $this->getCacheKeyFromCertLocation($certsLocation);
|
||||
$throwException = isset($options['throwException'])
|
||||
? $options['throwException']
|
||||
: false; // for backwards compatibility
|
||||
|
||||
// Check signature against each available cert.
|
||||
// allow the loop to complete unless a known bad result is encountered.
|
||||
$certs = $this->getFederatedSignOnCerts($certsLocation, $options);
|
||||
foreach ($certs as $cert) {
|
||||
$rsa = new RSA();
|
||||
$rsa->loadKey([
|
||||
'n' => new BigInteger($this->callJwtStatic('urlsafeB64Decode', [
|
||||
$cert['n']
|
||||
]), 256),
|
||||
'e' => new BigInteger($this->callJwtStatic('urlsafeB64Decode', [
|
||||
$cert['e']
|
||||
]), 256)
|
||||
]);
|
||||
|
||||
try {
|
||||
$pubkey = $rsa->getPublicKey();
|
||||
$payload = $this->callJwtStatic('decode', [
|
||||
$token,
|
||||
$pubkey,
|
||||
['RS256']
|
||||
]);
|
||||
|
||||
if (property_exists($payload, 'aud')) {
|
||||
if ($audience && $payload->aud != $audience) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// support HTTP and HTTPS issuers
|
||||
// @see https://developers.google.com/identity/sign-in/web/backend-auth
|
||||
$issuers = [self::OAUTH2_ISSUER, self::OAUTH2_ISSUER_HTTPS];
|
||||
if (!isset($payload->iss) || !in_array($payload->iss, $issuers)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (array) $payload;
|
||||
} catch (ExpiredException $e) {
|
||||
return false;
|
||||
} catch (\ExpiredException $e) {
|
||||
// (firebase/php-jwt 2)
|
||||
return false;
|
||||
} catch (SignatureInvalidException $e) {
|
||||
// continue
|
||||
} catch (\SignatureInvalidException $e) {
|
||||
// continue (firebase/php-jwt 2)
|
||||
} catch (\DomainException $e) {
|
||||
// continue
|
||||
$certs = $this->getCerts($certsLocation, $cacheKey, $options);
|
||||
$alg = $this->determineAlg($certs);
|
||||
if (!in_array($alg, ['RS256', 'ES256'])) {
|
||||
throw new InvalidArgumentException(
|
||||
'unrecognized "alg" in certs, expected ES256 or RS256');
|
||||
}
|
||||
try {
|
||||
if ($alg == 'RS256') {
|
||||
return $this->verifyRs256($token, $certs, $audience, $issuer);
|
||||
}
|
||||
return $this->verifyEs256($token, $certs, $audience, $issuer);
|
||||
} catch (ExpiredException $e) { // firebase/php-jwt 3+
|
||||
} catch (\ExpiredException $e) { // firebase/php-jwt 2
|
||||
} catch (SignatureInvalidException $e) { // firebase/php-jwt 3+
|
||||
} catch (\SignatureInvalidException $e) { // firebase/php-jwt 2
|
||||
} catch (InvalidTokenException $e) { // simplejwt
|
||||
} catch (DomainException $e) {
|
||||
} catch (InvalidArgumentException $e) {
|
||||
} catch (UnexpectedValueException $e) {
|
||||
}
|
||||
|
||||
if ($throwException) {
|
||||
throw $e;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Identifies the expected algorithm to verify by looking at the "alg" key
|
||||
* of the provided certs.
|
||||
*
|
||||
* @param array $certs Certificate array according to the JWK spec (see
|
||||
* https://tools.ietf.org/html/rfc7517).
|
||||
* @return string The expected algorithm, such as "ES256" or "RS256".
|
||||
*/
|
||||
private function determineAlg(array $certs)
|
||||
{
|
||||
$alg = null;
|
||||
foreach ($certs as $cert) {
|
||||
if (empty($cert['alg'])) {
|
||||
throw new InvalidArgumentException(
|
||||
'certs expects "alg" to be set'
|
||||
);
|
||||
}
|
||||
$alg = $alg ?: $cert['alg'];
|
||||
|
||||
if ($alg != $cert['alg']) {
|
||||
throw new InvalidArgumentException(
|
||||
'More than one alg detected in certs'
|
||||
);
|
||||
}
|
||||
}
|
||||
return $alg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies an ES256-signed JWT.
|
||||
*
|
||||
* @param string $token The JSON Web Token to be verified.
|
||||
* @param array $certs Certificate array according to the JWK spec (see
|
||||
* https://tools.ietf.org/html/rfc7517).
|
||||
* @param string|null $audience If set, returns false if the provided
|
||||
* audience does not match the "aud" claim on
|
||||
* the JWT.
|
||||
* @param string|null $issuer If set, returns false if the provided
|
||||
* issuer does not match the "iss" claim on
|
||||
* the JWT.
|
||||
* @return array|bool the token payload, if successful, or false if not.
|
||||
*/
|
||||
private function verifyEs256($token, array $certs, $audience = null, $issuer = null)
|
||||
{
|
||||
$this->checkSimpleJwt();
|
||||
|
||||
$jwkset = new KeySet();
|
||||
foreach ($certs as $cert) {
|
||||
$jwkset->add(KeyFactory::create($cert, 'php'));
|
||||
}
|
||||
|
||||
// Validate the signature using the key set and ES256 algorithm.
|
||||
$jwt = $this->callSimpleJwtDecode([$token, $jwkset, 'ES256']);
|
||||
$payload = $jwt->getClaims();
|
||||
|
||||
if (isset($payload['aud'])) {
|
||||
if ($audience && $payload['aud'] != $audience) {
|
||||
throw new UnexpectedValueException('Audience does not match');
|
||||
}
|
||||
}
|
||||
|
||||
// @see https://cloud.google.com/iap/docs/signed-headers-howto#verifying_the_jwt_payload
|
||||
$issuer = $issuer ?: self::IAP_ISSUER;
|
||||
if (!isset($payload['iss']) || $payload['iss'] !== $issuer) {
|
||||
throw new UnexpectedValueException('Issuer does not match');
|
||||
}
|
||||
|
||||
return $payload;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies an RS256-signed JWT.
|
||||
*
|
||||
* @param string $token The JSON Web Token to be verified.
|
||||
* @param array $certs Certificate array according to the JWK spec (see
|
||||
* https://tools.ietf.org/html/rfc7517).
|
||||
* @param string|null $audience If set, returns false if the provided
|
||||
* audience does not match the "aud" claim on
|
||||
* the JWT.
|
||||
* @param string|null $issuer If set, returns false if the provided
|
||||
* issuer does not match the "iss" claim on
|
||||
* the JWT.
|
||||
* @return array|bool the token payload, if successful, or false if not.
|
||||
*/
|
||||
private function verifyRs256($token, array $certs, $audience = null, $issuer = null)
|
||||
{
|
||||
$this->checkAndInitializePhpsec();
|
||||
$keys = [];
|
||||
foreach ($certs as $cert) {
|
||||
if (empty($cert['kid'])) {
|
||||
throw new InvalidArgumentException(
|
||||
'certs expects "kid" to be set'
|
||||
);
|
||||
}
|
||||
if (empty($cert['n']) || empty($cert['e'])) {
|
||||
throw new InvalidArgumentException(
|
||||
'RSA certs expects "n" and "e" to be set'
|
||||
);
|
||||
}
|
||||
$rsa = new RSA();
|
||||
$rsa->loadKey([
|
||||
'n' => new BigInteger($this->callJwtStatic('urlsafeB64Decode', [
|
||||
$cert['n'],
|
||||
]), 256),
|
||||
'e' => new BigInteger($this->callJwtStatic('urlsafeB64Decode', [
|
||||
$cert['e']
|
||||
]), 256),
|
||||
]);
|
||||
|
||||
// create an array of key IDs to certs for the JWT library
|
||||
$keys[$cert['kid']] = $rsa->getPublicKey();
|
||||
}
|
||||
|
||||
$payload = $this->callJwtStatic('decode', [
|
||||
$token,
|
||||
$keys,
|
||||
['RS256']
|
||||
]);
|
||||
|
||||
if (property_exists($payload, 'aud')) {
|
||||
if ($audience && $payload->aud != $audience) {
|
||||
throw new UnexpectedValueException('Audience does not match');
|
||||
}
|
||||
}
|
||||
|
||||
// support HTTP and HTTPS issuers
|
||||
// @see https://developers.google.com/identity/sign-in/web/backend-auth
|
||||
$issuers = $issuer ? [$issuer] : [self::OAUTH2_ISSUER, self::OAUTH2_ISSUER_HTTPS];
|
||||
if (!isset($payload->iss) || !in_array($payload->iss, $issuers)) {
|
||||
throw new UnexpectedValueException('Issuer does not match');
|
||||
}
|
||||
|
||||
return (array) $payload;
|
||||
}
|
||||
|
||||
/**
|
||||
* Revoke an OAuth2 access token or refresh token. This method will revoke the current access
|
||||
* token, if a token isn't provided.
|
||||
*
|
||||
* @param string|array $token The token (access token or a refresh token) that should be revoked.
|
||||
* @param array $options [optional] Configuration options.
|
||||
* @return boolean Returns True if the revocation was successful, otherwise False.
|
||||
* @return bool Returns True if the revocation was successful, otherwise False.
|
||||
*/
|
||||
public function revoke($token, array $options = [])
|
||||
{
|
||||
@ -198,11 +327,11 @@ class AccessToken
|
||||
* @param string $location The location from which to retrieve certs.
|
||||
* @param array $options [optional] Configuration options.
|
||||
* @return array
|
||||
* @throws \InvalidArgumentException If received certs are in an invalid format.
|
||||
* @throws InvalidArgumentException If received certs are in an invalid format.
|
||||
*/
|
||||
private function getFederatedSignOnCerts($location, array $options = [])
|
||||
private function getCerts($location, $cacheKey, array $options = [])
|
||||
{
|
||||
$cacheItem = $this->cache->getItem('federated_signon_certs_v3');
|
||||
$cacheItem = $this->cache->getItem($cacheKey);
|
||||
$certs = $cacheItem ? $cacheItem->get() : null;
|
||||
|
||||
$gotNewCerts = false;
|
||||
@ -213,15 +342,20 @@ class AccessToken
|
||||
}
|
||||
|
||||
if (!isset($certs['keys'])) {
|
||||
throw new \InvalidArgumentException(
|
||||
'federated sign-on certs expects "keys" to be set'
|
||||
if ($location !== self::IAP_CERT_URL) {
|
||||
throw new InvalidArgumentException(
|
||||
'federated sign-on certs expects "keys" to be set'
|
||||
);
|
||||
}
|
||||
throw new InvalidArgumentException(
|
||||
'certs expects "keys" to be set'
|
||||
);
|
||||
}
|
||||
|
||||
// Push caching off until after verifying certs are in a valid format.
|
||||
// Don't want to cache bad data.
|
||||
if ($gotNewCerts) {
|
||||
$cacheItem->expiresAt(new \DateTime('+1 hour'));
|
||||
$cacheItem->expiresAt(new DateTime('+1 hour'));
|
||||
$cacheItem->set($certs);
|
||||
$this->cache->save($cacheItem);
|
||||
}
|
||||
@ -234,17 +368,16 @@ class AccessToken
|
||||
*
|
||||
* @param $url string location
|
||||
* @param array $options [optional] Configuration options.
|
||||
* @throws \RuntimeException
|
||||
* @return array certificates
|
||||
* @throws \InvalidArgumentException If certs could not be retrieved from a local file.
|
||||
* @throws \RuntimeException If certs could not be retrieved from a remote location.
|
||||
* @throws InvalidArgumentException If certs could not be retrieved from a local file.
|
||||
* @throws RuntimeException If certs could not be retrieved from a remote location.
|
||||
*/
|
||||
private function retrieveCertsFromLocation($url, array $options = [])
|
||||
{
|
||||
// If we're retrieving a local file, just grab it.
|
||||
if (strpos($url, 'http') !== 0) {
|
||||
if (!file_exists($url)) {
|
||||
throw new \InvalidArgumentException(sprintf(
|
||||
throw new InvalidArgumentException(sprintf(
|
||||
'Failed to retrieve verification certificates from path: %s.',
|
||||
$url
|
||||
));
|
||||
@ -260,26 +393,30 @@ class AccessToken
|
||||
return json_decode((string) $response->getBody(), true);
|
||||
}
|
||||
|
||||
throw new \RuntimeException(sprintf(
|
||||
throw new RuntimeException(sprintf(
|
||||
'Failed to retrieve verification certificates: "%s".',
|
||||
$response->getBody()->getContents()
|
||||
), $response->getStatusCode());
|
||||
}
|
||||
|
||||
/**
|
||||
* Set required defaults for JWT.
|
||||
*/
|
||||
private function configureJwtService()
|
||||
private function checkAndInitializePhpsec()
|
||||
{
|
||||
$class = class_exists('Firebase\JWT\JWT')
|
||||
? 'Firebase\JWT\JWT'
|
||||
: '\JWT';
|
||||
|
||||
if (property_exists($class, 'leeway') && $class::$leeway < 1) {
|
||||
// Ensures JWT leeway is at least 1
|
||||
// @see https://github.com/google/google-api-php-client/issues/827
|
||||
$class::$leeway = 1;
|
||||
// @codeCoverageIgnoreStart
|
||||
if (!class_exists('phpseclib\Crypt\RSA')) {
|
||||
throw new RuntimeException('Please require phpseclib/phpseclib v2 to use this utility.');
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
||||
$this->setPhpsecConstants();
|
||||
}
|
||||
|
||||
private function checkSimpleJwt()
|
||||
{
|
||||
// @codeCoverageIgnoreStart
|
||||
if (!class_exists('SimpleJWT\JWT')) {
|
||||
throw new RuntimeException('Please require kelvinmo/simplejwt ^0.2 to use this utility.');
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
|
||||
/**
|
||||
@ -317,4 +454,31 @@ class AccessToken
|
||||
: 'JWT';
|
||||
return call_user_func_array([$class, $method], $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide a hook to mock calls to the JWT static methods.
|
||||
*
|
||||
* @param array $args
|
||||
* @return mixed
|
||||
*/
|
||||
protected function callSimpleJwtDecode(array $args = [])
|
||||
{
|
||||
return call_user_func_array(['SimpleJWT\JWT', 'decode'], $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a cache key based on the cert location using sha1 with the
|
||||
* exception of using "federated_signon_certs_v3" to preserve BC.
|
||||
*
|
||||
* @param string $certsLocation
|
||||
* @return string
|
||||
*/
|
||||
private function getCacheKeyFromCertLocation($certsLocation)
|
||||
{
|
||||
$key = $certsLocation === self::FEDERATED_SIGNON_CERT_URL
|
||||
? 'federated_signon_certs_v3'
|
||||
: sha1($certsLocation);
|
||||
|
||||
return 'google_auth_certs_cache|' . $key;
|
||||
}
|
||||
}
|
||||
|
@ -20,11 +20,13 @@ namespace Google\Auth;
|
||||
use DomainException;
|
||||
use Google\Auth\Credentials\AppIdentityCredentials;
|
||||
use Google\Auth\Credentials\GCECredentials;
|
||||
use Google\Auth\Credentials\ServiceAccountCredentials;
|
||||
use Google\Auth\HttpHandler\HttpClientCache;
|
||||
use Google\Auth\HttpHandler\HttpHandlerFactory;
|
||||
use Google\Auth\Middleware\AuthTokenMiddleware;
|
||||
use Google\Auth\Subscriber\AuthTokenSubscriber;
|
||||
use GuzzleHttp\Client;
|
||||
use InvalidArgumentException;
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
|
||||
/**
|
||||
@ -121,8 +123,9 @@ class ApplicationDefaultCredentials
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the default FetchAuthTokenInterface implementation to use
|
||||
* in this environment.
|
||||
* Obtains an AuthTokenMiddleware which will fetch an access token to use in
|
||||
* the Authorization header. The middleware is configured with 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.
|
||||
@ -165,7 +168,97 @@ class ApplicationDefaultCredentials
|
||||
}
|
||||
|
||||
if (is_null($creds)) {
|
||||
throw new \DomainException(self::notFound());
|
||||
throw new DomainException(self::notFound());
|
||||
}
|
||||
if (!is_null($cache)) {
|
||||
$creds = new FetchAuthTokenCache($creds, $cacheConfig, $cache);
|
||||
}
|
||||
return $creds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains an AuthTokenMiddleware which will fetch an ID token to use in the
|
||||
* Authorization header. The middleware is configured with the default
|
||||
* FetchAuthTokenInterface implementation to use in this environment.
|
||||
*
|
||||
* If supplied, $targetAudience is used to set the "aud" on the resulting
|
||||
* ID token.
|
||||
*
|
||||
* @param string $targetAudience The audience for the ID token.
|
||||
* @param callable $httpHandler callback which delivers psr7 request
|
||||
* @param array $cacheConfig configuration for the cache when it's present
|
||||
* @param CacheItemPoolInterface $cache
|
||||
*
|
||||
* @return AuthTokenMiddleware
|
||||
*
|
||||
* @throws DomainException if no implementation can be obtained.
|
||||
*/
|
||||
public static function getIdTokenMiddleware(
|
||||
$targetAudience,
|
||||
callable $httpHandler = null,
|
||||
array $cacheConfig = null,
|
||||
CacheItemPoolInterface $cache = null
|
||||
|
||||
) {
|
||||
$creds = self::getIdTokenCredentials($targetAudience, $httpHandler, $cacheConfig, $cache);
|
||||
|
||||
return new AuthTokenMiddleware($creds, $httpHandler);
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the default FetchAuthTokenInterface implementation to use
|
||||
* in this environment, configured with a $targetAudience for fetching an ID
|
||||
* token.
|
||||
*
|
||||
* @param string $targetAudience The audience for the ID token.
|
||||
* @param callable $httpHandler callback which delivers psr7 request
|
||||
* @param array $cacheConfig configuration for the cache when it's present
|
||||
* @param CacheItemPoolInterface $cache
|
||||
*
|
||||
* @return CredentialsLoader
|
||||
*
|
||||
* @throws DomainException if no implementation can be obtained.
|
||||
* @throws InvalidArgumentException if JSON "type" key is invalid
|
||||
*/
|
||||
public static function getIdTokenCredentials(
|
||||
$targetAudience,
|
||||
callable $httpHandler = null,
|
||||
array $cacheConfig = null,
|
||||
CacheItemPoolInterface $cache = null
|
||||
) {
|
||||
$creds = null;
|
||||
$jsonKey = CredentialsLoader::fromEnv()
|
||||
?: CredentialsLoader::fromWellKnownFile();
|
||||
|
||||
if (!$httpHandler) {
|
||||
if (!($client = HttpClientCache::getHttpClient())) {
|
||||
$client = new Client();
|
||||
HttpClientCache::setHttpClient($client);
|
||||
}
|
||||
|
||||
$httpHandler = HttpHandlerFactory::build($client);
|
||||
}
|
||||
|
||||
if (!is_null($jsonKey)) {
|
||||
if (!array_key_exists('type', $jsonKey)) {
|
||||
throw new \InvalidArgumentException('json key is missing the type field');
|
||||
}
|
||||
|
||||
if ($jsonKey['type'] == 'authorized_user') {
|
||||
throw new InvalidArgumentException('ID tokens are not supported for end user credentials');
|
||||
}
|
||||
|
||||
if ($jsonKey['type'] != 'service_account') {
|
||||
throw new InvalidArgumentException('invalid value in the type field');
|
||||
}
|
||||
|
||||
$creds = new ServiceAccountCredentials(null, $jsonKey, null, $targetAudience);
|
||||
} elseif (GCECredentials::onGce($httpHandler)) {
|
||||
$creds = new GCECredentials(null, null, $targetAudience);
|
||||
}
|
||||
|
||||
if (is_null($creds)) {
|
||||
throw new DomainException(self::notFound());
|
||||
}
|
||||
if (!is_null($cache)) {
|
||||
$creds = new FetchAuthTokenCache($creds, $cacheConfig, $cache);
|
||||
|
@ -76,7 +76,7 @@ class SysVCacheItemPool implements CacheItemPoolInterface
|
||||
public function __construct($options = [])
|
||||
{
|
||||
if (! extension_loaded('sysvshm')) {
|
||||
throw \RuntimeException(
|
||||
throw new \RuntimeException(
|
||||
'sysvshm extension is required to use this ItemPool');
|
||||
}
|
||||
$this->options = $options + [
|
||||
|
@ -24,6 +24,7 @@ namespace Google\Auth\Credentials;
|
||||
*/
|
||||
use google\appengine\api\app_identity\AppIdentityService;
|
||||
use Google\Auth\CredentialsLoader;
|
||||
use Google\Auth\ProjectIdProviderInterface;
|
||||
use Google\Auth\SignBlobInterface;
|
||||
|
||||
/**
|
||||
@ -32,35 +33,42 @@ use Google\Auth\SignBlobInterface;
|
||||
* 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;
|
||||
* Example:
|
||||
* ```
|
||||
* 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);
|
||||
* $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'
|
||||
* ]);
|
||||
* $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');
|
||||
* $res = $client->get('volumes?q=Henry+David+Thoreau&country=US');
|
||||
* ```
|
||||
*/
|
||||
class AppIdentityCredentials extends CredentialsLoader implements SignBlobInterface
|
||||
class AppIdentityCredentials extends CredentialsLoader implements
|
||||
SignBlobInterface,
|
||||
ProjectIdProviderInterface
|
||||
{
|
||||
/**
|
||||
* Result of fetchAuthToken.
|
||||
*
|
||||
* @array
|
||||
* @var array
|
||||
*/
|
||||
protected $lastReceivedToken;
|
||||
|
||||
/**
|
||||
* Array of OAuth2 scopes to be requested.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $scope;
|
||||
|
||||
@ -69,6 +77,9 @@ class AppIdentityCredentials extends CredentialsLoader implements SignBlobInterf
|
||||
*/
|
||||
private $clientName;
|
||||
|
||||
/**
|
||||
* @param array $scope One or more scopes.
|
||||
*/
|
||||
public function __construct($scope = array())
|
||||
{
|
||||
$this->scope = $scope;
|
||||
@ -143,6 +154,25 @@ class AppIdentityCredentials extends CredentialsLoader implements SignBlobInterf
|
||||
return base64_encode(AppIdentityService::signForApp($stringToSign)['signature']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the project ID from AppIdentityService.
|
||||
*
|
||||
* Returns null if AppIdentityService is unavailable.
|
||||
*
|
||||
* @param callable $httpHandler Not used by this type.
|
||||
* @return string|null
|
||||
*/
|
||||
public function getProjectId(callable $httpHander = null)
|
||||
{
|
||||
try {
|
||||
$this->checkAppEngineContext();
|
||||
} catch (\Exception $e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return AppIdentityService::getApplicationId();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the client name from AppIdentityService.
|
||||
*
|
||||
|
@ -21,11 +21,13 @@ use Google\Auth\CredentialsLoader;
|
||||
use Google\Auth\HttpHandler\HttpClientCache;
|
||||
use Google\Auth\HttpHandler\HttpHandlerFactory;
|
||||
use Google\Auth\Iam;
|
||||
use Google\Auth\ProjectIdProviderInterface;
|
||||
use Google\Auth\SignBlobInterface;
|
||||
use GuzzleHttp\Exception\ClientException;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use GuzzleHttp\Exception\ServerException;
|
||||
use GuzzleHttp\Psr7\Request;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* GCECredentials supports authorization on Google Compute Engine.
|
||||
@ -51,7 +53,9 @@ use GuzzleHttp\Psr7\Request;
|
||||
*
|
||||
* $res = $client->get('myproject/taskqueues/myqueue');
|
||||
*/
|
||||
class GCECredentials extends CredentialsLoader implements SignBlobInterface
|
||||
class GCECredentials extends CredentialsLoader implements
|
||||
SignBlobInterface,
|
||||
ProjectIdProviderInterface
|
||||
{
|
||||
const cacheKey = 'GOOGLE_AUTH_PHP_GCE';
|
||||
|
||||
@ -68,11 +72,21 @@ class GCECredentials extends CredentialsLoader implements SignBlobInterface
|
||||
*/
|
||||
const TOKEN_URI_PATH = 'v1/instance/service-accounts/default/token';
|
||||
|
||||
/**
|
||||
* The metadata path of the default id token.
|
||||
*/
|
||||
const ID_TOKEN_URI_PATH = 'v1/instance/service-accounts/default/identity';
|
||||
|
||||
/**
|
||||
* The metadata path of the client ID.
|
||||
*/
|
||||
const CLIENT_ID_URI_PATH = 'v1/instance/service-accounts/default/email';
|
||||
|
||||
/**
|
||||
* The metadata path of the project ID.
|
||||
*/
|
||||
const PROJECT_ID_URI_PATH = 'v1/project/project-id';
|
||||
|
||||
/**
|
||||
* The header whose presence indicates GCE presence.
|
||||
*/
|
||||
@ -111,10 +125,15 @@ class GCECredentials extends CredentialsLoader implements SignBlobInterface
|
||||
protected $lastReceivedToken;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
* @var string|null
|
||||
*/
|
||||
private $clientName;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
private $projectId;
|
||||
|
||||
/**
|
||||
* @var Iam|null
|
||||
*/
|
||||
@ -125,15 +144,26 @@ class GCECredentials extends CredentialsLoader implements SignBlobInterface
|
||||
*/
|
||||
private $tokenUri;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $targetAudience;
|
||||
|
||||
/**
|
||||
* @param Iam $iam [optional] An IAM instance.
|
||||
* @param string|array $scope [optional] the scope of the access request,
|
||||
* expressed either as an array or as a space-delimited string.
|
||||
* @param string $targetAudience [optional] The audience for the ID token.
|
||||
*/
|
||||
public function __construct(Iam $iam = null, $scope = null)
|
||||
public function __construct(Iam $iam = null, $scope = null, $targetAudience = null)
|
||||
{
|
||||
$this->iam = $iam;
|
||||
|
||||
if ($scope && $targetAudience) {
|
||||
throw new InvalidArgumentException(
|
||||
'Scope and targetAudience cannot both be supplied');
|
||||
}
|
||||
|
||||
$tokenUri = self::getTokenUri();
|
||||
if ($scope) {
|
||||
if (is_string($scope)) {
|
||||
@ -143,6 +173,13 @@ class GCECredentials extends CredentialsLoader implements SignBlobInterface
|
||||
$scope = implode(',', $scope);
|
||||
|
||||
$tokenUri = $tokenUri . '?scopes='. $scope;
|
||||
} elseif ($targetAudience) {
|
||||
$tokenUri = sprintf('http://%s/computeMetadata/%s?audience=%s',
|
||||
self::METADATA_IP,
|
||||
self::ID_TOKEN_URI_PATH,
|
||||
$targetAudience
|
||||
);
|
||||
$this->targetAudience = $targetAudience;
|
||||
}
|
||||
|
||||
$this->tokenUri = $tokenUri;
|
||||
@ -172,6 +209,18 @@ class GCECredentials extends CredentialsLoader implements SignBlobInterface
|
||||
return $base . self::CLIENT_ID_URI_PATH;
|
||||
}
|
||||
|
||||
/**
|
||||
* The full uri for accessing the default project ID.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function getProjectIdUri()
|
||||
{
|
||||
$base = 'http://' . self::METADATA_IP . '/computeMetadata/';
|
||||
|
||||
return $base . self::PROJECT_ID_URI_PATH;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if this an App Engine Flexible instance, by accessing the
|
||||
* GAE_INSTANCE environment variable.
|
||||
@ -189,8 +238,7 @@ class GCECredentials extends CredentialsLoader implements SignBlobInterface
|
||||
* 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
|
||||
* @return bool True if this a GCEInstance, false otherwise
|
||||
*/
|
||||
public static function onGce(callable $httpHandler = null)
|
||||
{
|
||||
@ -234,11 +282,14 @@ class GCECredentials extends CredentialsLoader implements SignBlobInterface
|
||||
*
|
||||
* @param callable $httpHandler callback which delivers psr7 request
|
||||
*
|
||||
* @return array A set of auth related metadata, containing the following
|
||||
* keys:
|
||||
* @return array A set of auth related metadata, based on the token type.
|
||||
*
|
||||
* Access tokens have the following keys:
|
||||
* - access_token (string)
|
||||
* - expires_in (int)
|
||||
* - token_type (string)
|
||||
* ID tokens have the following keys:
|
||||
* - id_token (string)
|
||||
*
|
||||
* @throws \Exception
|
||||
*/
|
||||
@ -255,8 +306,13 @@ class GCECredentials extends CredentialsLoader implements SignBlobInterface
|
||||
return array(); // return an empty array with no access token
|
||||
}
|
||||
|
||||
$json = $this->getFromMetadata($httpHandler, $this->tokenUri);
|
||||
if (null === $json = json_decode($json, true)) {
|
||||
$response = $this->getFromMetadata($httpHandler, $this->tokenUri);
|
||||
|
||||
if ($this->targetAudience) {
|
||||
return ['id_token' => $response];
|
||||
}
|
||||
|
||||
if (null === $json = json_decode($response, true)) {
|
||||
throw new \Exception('Invalid JSON response');
|
||||
}
|
||||
|
||||
@ -351,6 +407,36 @@ class GCECredentials extends CredentialsLoader implements SignBlobInterface
|
||||
return $signer->signBlob($email, $accessToken, $stringToSign);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the default Project ID from compute engine.
|
||||
*
|
||||
* Returns null if called outside GCE.
|
||||
*
|
||||
* @param callable $httpHandler Callback which delivers psr7 request
|
||||
* @return string|null
|
||||
*/
|
||||
public function getProjectId(callable $httpHandler = null)
|
||||
{
|
||||
if ($this->projectId) {
|
||||
return $this->projectId;
|
||||
}
|
||||
|
||||
$httpHandler = $httpHandler
|
||||
?: HttpHandlerFactory::build(HttpClientCache::getHttpClient());
|
||||
|
||||
if (!$this->hasCheckedOnGce) {
|
||||
$this->isOnGce = self::onGce($httpHandler);
|
||||
$this->hasCheckedOnGce = true;
|
||||
}
|
||||
|
||||
if (!$this->isOnGce) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->projectId = $this->getFromMetadata($httpHandler, self::getProjectIdUri());
|
||||
return $this->projectId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch the value of a GCE metadata server URI.
|
||||
*
|
||||
|
@ -18,9 +18,12 @@
|
||||
namespace Google\Auth\Credentials;
|
||||
|
||||
use Google\Auth\CredentialsLoader;
|
||||
use Google\Auth\GetQuotaProjectInterface;
|
||||
use Google\Auth\OAuth2;
|
||||
use Google\Auth\ProjectIdProviderInterface;
|
||||
use Google\Auth\ServiceAccountSignerTrait;
|
||||
use Google\Auth\SignBlobInterface;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* ServiceAccountCredentials supports authorization using a Google service
|
||||
@ -55,7 +58,10 @@ use Google\Auth\SignBlobInterface;
|
||||
*
|
||||
* $res = $client->get('myproject/taskqueues/myqueue');
|
||||
*/
|
||||
class ServiceAccountCredentials extends CredentialsLoader implements SignBlobInterface
|
||||
class ServiceAccountCredentials extends CredentialsLoader implements
|
||||
GetQuotaProjectInterface,
|
||||
SignBlobInterface,
|
||||
ProjectIdProviderInterface
|
||||
{
|
||||
use ServiceAccountSignerTrait;
|
||||
|
||||
@ -66,6 +72,18 @@ class ServiceAccountCredentials extends CredentialsLoader implements SignBlobInt
|
||||
*/
|
||||
protected $auth;
|
||||
|
||||
/**
|
||||
* The quota project associated with the JSON credentials
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $quotaProject;
|
||||
|
||||
/*
|
||||
* @var string|null
|
||||
*/
|
||||
protected $projectId;
|
||||
|
||||
/**
|
||||
* Create a new ServiceAccountCredentials.
|
||||
*
|
||||
@ -75,11 +93,13 @@ class ServiceAccountCredentials extends CredentialsLoader implements SignBlobInt
|
||||
* 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.
|
||||
* @param string $targetAudience The audience for the ID token.
|
||||
*/
|
||||
public function __construct(
|
||||
$scope,
|
||||
$jsonKey,
|
||||
$sub = null
|
||||
$sub = null,
|
||||
$targetAudience = null
|
||||
) {
|
||||
if (is_string($jsonKey)) {
|
||||
if (!file_exists($jsonKey)) {
|
||||
@ -98,6 +118,17 @@ class ServiceAccountCredentials extends CredentialsLoader implements SignBlobInt
|
||||
throw new \InvalidArgumentException(
|
||||
'json key is missing the private_key field');
|
||||
}
|
||||
if (array_key_exists('quota_project', $jsonKey)) {
|
||||
$this->quotaProject = (string) $jsonKey['quota_project'];
|
||||
}
|
||||
if ($scope && $targetAudience) {
|
||||
throw new InvalidArgumentException(
|
||||
'Scope and targetAudience cannot both be supplied');
|
||||
}
|
||||
$additionalClaims = [];
|
||||
if ($targetAudience) {
|
||||
$additionalClaims = ['target_audience' => $targetAudience];
|
||||
}
|
||||
$this->auth = new OAuth2([
|
||||
'audience' => self::TOKEN_CREDENTIAL_URI,
|
||||
'issuer' => $jsonKey['client_email'],
|
||||
@ -106,7 +137,12 @@ class ServiceAccountCredentials extends CredentialsLoader implements SignBlobInt
|
||||
'signingKey' => $jsonKey['private_key'],
|
||||
'sub' => $sub,
|
||||
'tokenCredentialUri' => self::TOKEN_CREDENTIAL_URI,
|
||||
'additionalClaims' => $additionalClaims,
|
||||
]);
|
||||
|
||||
$this->projectId = isset($jsonKey['project_id'])
|
||||
? $jsonKey['project_id']
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -144,6 +180,19 @@ class ServiceAccountCredentials extends CredentialsLoader implements SignBlobInt
|
||||
return $this->auth->getLastReceivedToken();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the project ID from the service account keyfile.
|
||||
*
|
||||
* Returns null if the project ID does not exist in the keyfile.
|
||||
*
|
||||
* @param callable $httpHandler Not used by this credentials type.
|
||||
* @return string|null
|
||||
*/
|
||||
public function getProjectId(callable $httpHandler = null)
|
||||
{
|
||||
return $this->projectId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates metadata with the authorization token.
|
||||
*
|
||||
@ -195,4 +244,14 @@ class ServiceAccountCredentials extends CredentialsLoader implements SignBlobInt
|
||||
{
|
||||
return $this->auth->getIssuer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the quota project used for this API request
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getQuotaProject()
|
||||
{
|
||||
return $this->quotaProject;
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,9 @@
|
||||
namespace Google\Auth\Credentials;
|
||||
|
||||
use Google\Auth\CredentialsLoader;
|
||||
use Google\Auth\GetQuotaProjectInterface;
|
||||
use Google\Auth\OAuth2;
|
||||
use Google\Auth\ProjectIdProviderInterface;
|
||||
use Google\Auth\ServiceAccountSignerTrait;
|
||||
use Google\Auth\SignBlobInterface;
|
||||
|
||||
@ -31,7 +33,10 @@ use Google\Auth\SignBlobInterface;
|
||||
* 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 implements SignBlobInterface
|
||||
class ServiceAccountJwtAccessCredentials extends CredentialsLoader implements
|
||||
GetQuotaProjectInterface,
|
||||
SignBlobInterface,
|
||||
ProjectIdProviderInterface
|
||||
{
|
||||
use ServiceAccountSignerTrait;
|
||||
|
||||
@ -42,6 +47,11 @@ class ServiceAccountJwtAccessCredentials extends CredentialsLoader implements Si
|
||||
*/
|
||||
protected $auth;
|
||||
|
||||
/**
|
||||
* The quota project associated with the JSON credentials
|
||||
*/
|
||||
protected $quotaProject;
|
||||
|
||||
/**
|
||||
* Create a new ServiceAccountJwtAccessCredentials.
|
||||
*
|
||||
@ -67,12 +77,19 @@ class ServiceAccountJwtAccessCredentials extends CredentialsLoader implements Si
|
||||
throw new \InvalidArgumentException(
|
||||
'json key is missing the private_key field');
|
||||
}
|
||||
if (array_key_exists('quota_project', $jsonKey)) {
|
||||
$this->quotaProject = (string) $jsonKey['quota_project'];
|
||||
}
|
||||
$this->auth = new OAuth2([
|
||||
'issuer' => $jsonKey['client_email'],
|
||||
'sub' => $jsonKey['client_email'],
|
||||
'signingAlgorithm' => 'RS256',
|
||||
'signingKey' => $jsonKey['private_key'],
|
||||
]);
|
||||
|
||||
$this->projectId = isset($jsonKey['project_id'])
|
||||
? $jsonKey['project_id']
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -135,6 +152,19 @@ class ServiceAccountJwtAccessCredentials extends CredentialsLoader implements Si
|
||||
return $this->auth->getLastReceivedToken();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the project ID from the service account keyfile.
|
||||
*
|
||||
* Returns null if the project ID does not exist in the keyfile.
|
||||
*
|
||||
* @param callable $httpHandler Not used by this credentials type.
|
||||
* @return string|null
|
||||
*/
|
||||
public function getProjectId(callable $httpHandler = null)
|
||||
{
|
||||
return $this->projectId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the client name from the keyfile.
|
||||
*
|
||||
@ -147,4 +177,14 @@ class ServiceAccountJwtAccessCredentials extends CredentialsLoader implements Si
|
||||
{
|
||||
return $this->auth->getIssuer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the quota project used for this API request
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getQuotaProject()
|
||||
{
|
||||
return $this->quotaProject;
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@
|
||||
namespace Google\Auth\Credentials;
|
||||
|
||||
use Google\Auth\CredentialsLoader;
|
||||
use Google\Auth\GetQuotaProjectInterface;
|
||||
use Google\Auth\OAuth2;
|
||||
|
||||
/**
|
||||
@ -31,7 +32,7 @@ use Google\Auth\OAuth2;
|
||||
*
|
||||
* @see [Application Default Credentials](http://goo.gl/mkAHpZ)
|
||||
*/
|
||||
class UserRefreshCredentials extends CredentialsLoader
|
||||
class UserRefreshCredentials extends CredentialsLoader implements GetQuotaProjectInterface
|
||||
{
|
||||
const CLOUD_SDK_CLIENT_ID =
|
||||
'764086051850-6qr4p6gpi6hn506pt8ejuq83di341hur.apps.googleusercontent.com';
|
||||
@ -45,6 +46,11 @@ class UserRefreshCredentials extends CredentialsLoader
|
||||
*/
|
||||
protected $auth;
|
||||
|
||||
/**
|
||||
* The quota project associated with the JSON credentials
|
||||
*/
|
||||
protected $quotaProject;
|
||||
|
||||
/**
|
||||
* Create a new UserRefreshCredentials.
|
||||
*
|
||||
@ -85,7 +91,11 @@ class UserRefreshCredentials extends CredentialsLoader
|
||||
'scope' => $scope,
|
||||
'tokenCredentialUri' => self::TOKEN_CREDENTIAL_URI,
|
||||
]);
|
||||
if (array_key_exists('quota_project', $jsonKey)) {
|
||||
$this->quotaProject = (string) $jsonKey['quota_project'];
|
||||
}
|
||||
if ($jsonKey['client_id'] === self::CLOUD_SDK_CLIENT_ID
|
||||
&& is_null($this->quotaProject)
|
||||
&& getenv(self::SUPPRESS_CLOUD_SDK_CREDS_WARNING_ENV) !== 'true') {
|
||||
trigger_error(
|
||||
'Your application has authenticated using end user credentials '
|
||||
@ -134,4 +144,14 @@ class UserRefreshCredentials extends CredentialsLoader
|
||||
{
|
||||
return $this->auth->getLastReceivedToken();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the quota project used for this API request
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getQuotaProject()
|
||||
{
|
||||
return $this->quotaProject;
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,11 @@ use Psr\Cache\CacheItemPoolInterface;
|
||||
* A class to implement caching for any object implementing
|
||||
* FetchAuthTokenInterface
|
||||
*/
|
||||
class FetchAuthTokenCache implements FetchAuthTokenInterface, SignBlobInterface
|
||||
class FetchAuthTokenCache implements
|
||||
FetchAuthTokenInterface,
|
||||
GetQuotaProjectInterface,
|
||||
SignBlobInterface,
|
||||
ProjectIdProviderInterface
|
||||
{
|
||||
use CacheTrait;
|
||||
|
||||
@ -139,4 +143,37 @@ class FetchAuthTokenCache implements FetchAuthTokenInterface, SignBlobInterface
|
||||
|
||||
return $this->fetcher->signBlob($stringToSign, $forceOpenSsl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the quota project used for this API request from the credentials
|
||||
* fetcher.
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getQuotaProject()
|
||||
{
|
||||
if ($this->fetcher instanceof GetQuotaProjectInterface) {
|
||||
return $this->fetcher->getQuotaProject();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the Project ID from the fetcher.
|
||||
*
|
||||
* @param callable $httpHandler Callback which delivers psr7 request
|
||||
* @return string|null
|
||||
* @throws \RuntimeException If the fetcher does not implement
|
||||
* `Google\Auth\ProvidesProjectIdInterface`.
|
||||
*/
|
||||
public function getProjectId(callable $httpHandler = null)
|
||||
{
|
||||
if (!$this->fetcher instanceof ProjectIdProviderInterface) {
|
||||
throw new \RuntimeException(
|
||||
'Credentials fetcher does not implement ' .
|
||||
'Google\Auth\ProvidesProjectIdInterface'
|
||||
);
|
||||
}
|
||||
|
||||
return $this->fetcher->getProjectId($httpHandler);
|
||||
}
|
||||
}
|
||||
|
33
wp-content/plugins/wp-mail-smtp/vendor/google/auth/src/GetQuotaProjectInterface.php
vendored
Normal file
33
wp-content/plugins/wp-mail-smtp/vendor/google/auth/src/GetQuotaProjectInterface.php
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright 2019 Google LLC
|
||||
*
|
||||
* 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 Google\Auth;
|
||||
|
||||
/**
|
||||
* An interface implemented by objects that can get quota projects.
|
||||
*/
|
||||
interface GetQuotaProjectInterface
|
||||
{
|
||||
const X_GOOG_USER_PROJECT_HEADER = 'X-Goog-User-Project';
|
||||
|
||||
/**
|
||||
* Get the quota project used for this API request
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getQuotaProject();
|
||||
}
|
@ -18,6 +18,7 @@
|
||||
namespace Google\Auth\Middleware;
|
||||
|
||||
use Google\Auth\FetchAuthTokenInterface;
|
||||
use Google\Auth\GetQuotaProjectInterface;
|
||||
use Psr\Http\Message\RequestInterface;
|
||||
|
||||
/**
|
||||
@ -101,6 +102,13 @@ class AuthTokenMiddleware
|
||||
|
||||
$request = $request->withHeader('authorization', 'Bearer ' . $this->fetchToken());
|
||||
|
||||
if ($quotaProject = $this->getQuotaProject()) {
|
||||
$request = $request->withHeader(
|
||||
GetQuotaProjectInterface::X_GOOG_USER_PROJECT_HEADER,
|
||||
$quotaProject
|
||||
);
|
||||
}
|
||||
|
||||
return $handler($request, $options);
|
||||
};
|
||||
}
|
||||
@ -122,5 +130,16 @@ class AuthTokenMiddleware
|
||||
|
||||
return $auth_tokens['access_token'];
|
||||
}
|
||||
|
||||
if (array_key_exists('id_token', $auth_tokens)) {
|
||||
return $auth_tokens['id_token'];
|
||||
}
|
||||
}
|
||||
|
||||
private function getQuotaProject()
|
||||
{
|
||||
if ($this->fetcher instanceof GetQuotaProjectInterface) {
|
||||
return $this->fetcher->getQuotaProject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
32
wp-content/plugins/wp-mail-smtp/vendor/google/auth/src/ProjectIdProviderInterface.php
vendored
Normal file
32
wp-content/plugins/wp-mail-smtp/vendor/google/auth/src/ProjectIdProviderInterface.php
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright 2020 Google LLC
|
||||
*
|
||||
* 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 Google\Auth;
|
||||
|
||||
/**
|
||||
* Describes a Credentials object which supports fetching the project ID.
|
||||
*/
|
||||
interface ProjectIdProviderInterface
|
||||
{
|
||||
/**
|
||||
* Get the project ID.
|
||||
*
|
||||
* @param callable $httpHandler Callback which delivers psr7 request
|
||||
* @return string|null
|
||||
*/
|
||||
public function getProjectId(callable $httpHandler = null);
|
||||
}
|
@ -18,6 +18,7 @@
|
||||
namespace Google\Auth\Subscriber;
|
||||
|
||||
use Google\Auth\FetchAuthTokenInterface;
|
||||
use Google\Auth\GetQuotaProjectInterface;
|
||||
use GuzzleHttp\Event\BeforeEvent;
|
||||
use GuzzleHttp\Event\RequestEvents;
|
||||
use GuzzleHttp\Event\SubscriberInterface;
|
||||
@ -114,5 +115,19 @@ class AuthTokenSubscriber implements SubscriberInterface
|
||||
call_user_func($this->tokenCallback, $this->fetcher->getCacheKey(), $auth_tokens['access_token']);
|
||||
}
|
||||
}
|
||||
|
||||
if ($quotaProject = $this->getQuotaProject()) {
|
||||
$request->setHeader(
|
||||
GetQuotaProjectInterface::X_GOOG_USER_PROJECT_HEADER,
|
||||
$quotaProject
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private function getQuotaProject()
|
||||
{
|
||||
if ($this->fetcher instanceof GetQuotaProjectInterface) {
|
||||
return $this->fetcher->getQuotaProject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user