diff --git a/php/composer.json b/php/composer.json index 8e77167..2ce3b9c 100644 --- a/php/composer.json +++ b/php/composer.json @@ -1,6 +1,6 @@ { "require": { - "google/auth": "^1.18", + "google/auth": "^1.42.0", "guzzlehttp/guzzle": "*", "google/apiclient": "^2.15", "google/apiclient-services": "~0.300" diff --git a/php/demo_eventticket.php b/php/demo_eventticket.php index 923bdb7..e4d5bbe 100644 --- a/php/demo_eventticket.php +++ b/php/demo_eventticket.php @@ -83,12 +83,12 @@ public function auth() Walletobjects::WALLET_OBJECT_ISSUER, $this->keyFilePath ); + $this->credentials->useJwtAccessWithScope(); // Initialize Google Wallet API service - $this->client = new GoogleClient(); + $this->client = new GoogleClient(['credentials' => $this->credentials]); $this->client->setApplicationName('APPLICATION_NAME'); $this->client->setScopes(Walletobjects::WALLET_OBJECT_ISSUER); - $this->client->setAuthConfig($this->keyFilePath); $this->service = new Walletobjects($this->client); } @@ -851,12 +851,9 @@ public function createJwtExistingObjects(string $issuerId) ] ]; - // The service account credentials are used to sign the JWT - $serviceAccount = json_decode(file_get_contents($this->keyFilePath), true); - // Create the JWT as an array of key/value pairs $claims = [ - 'iss' => $serviceAccount['client_email'], + 'iss' => $this->credentials->getClientName(), 'aud' => 'google', 'origins' => ['www.example.com'], 'typ' => 'savetowallet', @@ -865,7 +862,7 @@ public function createJwtExistingObjects(string $issuerId) $token = JWT::encode( $claims, - $serviceAccount['private_key'], + $this->credentials->getPrivateKey(), 'RS256' ); diff --git a/php/demo_flight.php b/php/demo_flight.php index c592c31..8053d98 100644 --- a/php/demo_flight.php +++ b/php/demo_flight.php @@ -87,12 +87,12 @@ public function auth() Walletobjects::WALLET_OBJECT_ISSUER, $this->keyFilePath ); + $this->credentials->useJwtAccessWithScope(); // Initialize Google Wallet API service - $this->client = new GoogleClient(); + $this->client = new GoogleClient(['credentials' => $this->credentials]); $this->client->setApplicationName('APPLICATION_NAME'); $this->client->setScopes(Walletobjects::WALLET_OBJECT_ISSUER); - $this->client->setAuthConfig($this->keyFilePath); $this->service = new Walletobjects($this->client); } @@ -836,12 +836,9 @@ public function createJwtExistingObjects(string $issuerId) ] ]; - // The service account credentials are used to sign the JWT - $serviceAccount = json_decode(file_get_contents($this->keyFilePath), true); - // Create the JWT as an array of key/value pairs $claims = [ - 'iss' => $serviceAccount['client_email'], + 'iss' => $this->credentials->getClientName(), 'aud' => 'google', 'origins' => ['www.example.com'], 'typ' => 'savetowallet', @@ -850,7 +847,7 @@ public function createJwtExistingObjects(string $issuerId) $token = JWT::encode( $claims, - $serviceAccount['private_key'], + $this->credentials->getPrivateKey(), 'RS256' ); diff --git a/php/demo_generic.php b/php/demo_generic.php index 90f76f3..d4fb024 100644 --- a/php/demo_generic.php +++ b/php/demo_generic.php @@ -79,12 +79,12 @@ public function auth() Walletobjects::WALLET_OBJECT_ISSUER, $this->keyFilePath ); + $this->credentials->useJwtAccessWithScope(); // Initialize Google Wallet API service - $this->client = new GoogleClient(); + $this->client = new GoogleClient(['credentials' => $this->credentials]); $this->client->setApplicationName('APPLICATION_NAME'); $this->client->setScopes(Walletobjects::WALLET_OBJECT_ISSUER); - $this->client->setAuthConfig($this->keyFilePath); $this->service = new Walletobjects($this->client); } @@ -749,12 +749,9 @@ public function createJwtExistingObjects(string $issuerId) ] ]; - // The service account credentials are used to sign the JWT - $serviceAccount = json_decode(file_get_contents($this->keyFilePath), true); - // Create the JWT as an array of key/value pairs $claims = [ - 'iss' => $serviceAccount['client_email'], + 'iss' => $this->credentials->getClientName(), 'aud' => 'google', 'origins' => ['www.example.com'], 'typ' => 'savetowallet', @@ -763,7 +760,7 @@ public function createJwtExistingObjects(string $issuerId) $token = JWT::encode( $claims, - $serviceAccount['private_key'], + $this->credentials->getPrivateKey(), 'RS256' ); diff --git a/php/demo_giftcard.php b/php/demo_giftcard.php index 799a042..6403c9d 100644 --- a/php/demo_giftcard.php +++ b/php/demo_giftcard.php @@ -84,12 +84,12 @@ public function auth() Walletobjects::WALLET_OBJECT_ISSUER, $this->keyFilePath ); + $this->credentials->useJwtAccessWithScope(); // Initialize Google Wallet API service - $this->client = new GoogleClient(); + $this->client = new GoogleClient(['credentials' => $this->credentials]); $this->client->setApplicationName('APPLICATION_NAME'); $this->client->setScopes(Walletobjects::WALLET_OBJECT_ISSUER); - $this->client->setAuthConfig($this->keyFilePath); $this->service = new Walletobjects($this->client); } @@ -801,12 +801,9 @@ public function createJwtExistingObjects(string $issuerId) ] ]; - // The service account credentials are used to sign the JWT - $serviceAccount = json_decode(file_get_contents($this->keyFilePath), true); - // Create the JWT as an array of key/value pairs $claims = [ - 'iss' => $serviceAccount['client_email'], + 'iss' => $this->credentials->getClientName(), 'aud' => 'google', 'origins' => ['www.example.com'], 'typ' => 'savetowallet', @@ -815,7 +812,7 @@ public function createJwtExistingObjects(string $issuerId) $token = JWT::encode( $claims, - $serviceAccount['private_key'], + $this->credentials->getPrivateKey(), 'RS256' ); diff --git a/php/demo_loyalty.php b/php/demo_loyalty.php index aaa3a9a..336640b 100644 --- a/php/demo_loyalty.php +++ b/php/demo_loyalty.php @@ -84,12 +84,12 @@ public function auth() Walletobjects::WALLET_OBJECT_ISSUER, $this->keyFilePath ); + $this->credentials->useJwtAccessWithScope(); // Initialize Google Wallet API service - $this->client = new GoogleClient(); + $this->client = new GoogleClient(['credentials' => $this->credentials]); $this->client->setApplicationName('APPLICATION_NAME'); $this->client->setScopes(Walletobjects::WALLET_OBJECT_ISSUER); - $this->client->setAuthConfig($this->keyFilePath); $this->service = new Walletobjects($this->client); } @@ -707,12 +707,9 @@ public function createJwtNewObjects(string $issuerId, string $classSuffix, strin ]) ]); - // The service account credentials are used to sign the JWT - $serviceAccount = json_decode(file_get_contents($this->keyFilePath), true); - // Create the JWT as an array of key/value pairs $claims = [ - 'iss' => $serviceAccount['client_email'], + 'iss' => $this->credentials->getClientName(), 'aud' => 'google', 'origins' => ['www.example.com'], 'typ' => 'savetowallet', @@ -728,7 +725,7 @@ public function createJwtNewObjects(string $issuerId, string $classSuffix, strin $token = JWT::encode( $claims, - $serviceAccount['private_key'], + $this->credentials->getPrivateKey(), 'RS256' ); diff --git a/php/demo_offer.php b/php/demo_offer.php index 4ae5aff..02ef45c 100644 --- a/php/demo_offer.php +++ b/php/demo_offer.php @@ -84,12 +84,12 @@ public function auth() Walletobjects::WALLET_OBJECT_ISSUER, $this->keyFilePath ); + $this->credentials->useJwtAccessWithScope(); // Initialize Google Wallet API service - $this->client = new GoogleClient(); + $this->client = new GoogleClient(['credentials' => $this->credentials]); $this->client->setApplicationName('APPLICATION_NAME'); $this->client->setScopes(Walletobjects::WALLET_OBJECT_ISSUER); - $this->client->setAuthConfig($this->keyFilePath); $this->service = new Walletobjects($this->client); } @@ -690,12 +690,9 @@ public function createJwtNewObjects(string $issuerId, string $classSuffix, strin ]) ]); - // The service account credentials are used to sign the JWT - $serviceAccount = json_decode(file_get_contents($this->keyFilePath), true); - // Create the JWT as an array of key/value pairs $claims = [ - 'iss' => $serviceAccount['client_email'], + 'iss' => $this->credentials->getClientName(), 'aud' => 'google', 'origins' => ['www.example.com'], 'typ' => 'savetowallet', @@ -711,7 +708,7 @@ public function createJwtNewObjects(string $issuerId, string $classSuffix, strin $token = JWT::encode( $claims, - $serviceAccount['private_key'], + $this->credentials->getPrivateKey(), 'RS256' ); diff --git a/php/demo_transit.php b/php/demo_transit.php index 47dd1e8..d47edc0 100644 --- a/php/demo_transit.php +++ b/php/demo_transit.php @@ -83,12 +83,12 @@ public function auth() Walletobjects::WALLET_OBJECT_ISSUER, $this->keyFilePath ); + $this->credentials->useJwtAccessWithScope(); // Initialize Google Wallet API service - $this->client = new GoogleClient(); + $this->client = new GoogleClient(['credentials' => $this->credentials]); $this->client->setApplicationName('APPLICATION_NAME'); $this->client->setScopes(Walletobjects::WALLET_OBJECT_ISSUER); - $this->client->setAuthConfig($this->keyFilePath); $this->service = new Walletobjects($this->client); } @@ -860,12 +860,9 @@ public function createJwtExistingObjects(string $issuerId) ] ]; - // The service account credentials are used to sign the JWT - $serviceAccount = json_decode(file_get_contents($this->keyFilePath), true); - // Create the JWT as an array of key/value pairs $claims = [ - 'iss' => $serviceAccount['client_email'], + 'iss' => $this->credentials->getClientName(), 'aud' => 'google', 'origins' => ['www.example.com'], 'typ' => 'savetowallet', @@ -874,7 +871,7 @@ public function createJwtExistingObjects(string $issuerId) $token = JWT::encode( $claims, - $serviceAccount['private_key'], + $this->credentials->getPrivateKey(), 'RS256' );