/**
  * Test fetching an access token with assertion credentials
  * using "setAuthConfig" and "setSubject" but with user credentials
  */
 public function testBadSubjectThrowsException()
 {
     $this->checkServiceAccountCredentials();
     $client = $this->getClient();
     $client->useApplicationDefaultCredentials();
     $client->setSubject('bad-subject');
     $authHandler = Google_AuthHandler_AuthHandlerFactory::build();
     // make this method public for testing purposes
     $method = new ReflectionMethod($authHandler, 'createAuthHttp');
     $method->setAccessible(true);
     $authHttp = $method->invoke($authHandler, $client->getHttpClient());
     try {
         $token = $client->fetchAccessTokenWithAssertion($authHttp);
         $this->fail('no exception thrown');
     } catch (GuzzleHttp\Exception\ClientException $e) {
         $response = $e->getResponse();
         $this->assertContains('Invalid impersonation prn email address', (string) $response->getBody());
     }
 }
 protected function getAuthHandler()
 {
     return Google_AuthHandler_AuthHandlerFactory::build($this->getCache());
 }
Example #3
0
 protected function getAuthHandler()
 {
     // Be very careful using the cache, as the underlying auth library's cache
     // implementation is naive, and the cache keys do not account for user
     // sessions.
     //
     // @see https://github.com/google/google-api-php-client/issues/821
     return Google_AuthHandler_AuthHandlerFactory::build($this->getCache(), $this->config['cache_config']);
 }
Example #4
0
 protected function getAuthHandler()
 {
     // we intentionally do not use the cache because
     // the underlying auth library's cache implementation
     // is broken.
     // @see https://github.com/google/google-api-php-client/issues/821
     return Google_AuthHandler_AuthHandlerFactory::build();
 }