Skip to content

Commit

Permalink
allow to get project id from ServiceAccountCredentials
Browse files Browse the repository at this point in the history
  • Loading branch information
tiptopcoder committed Jan 2, 2020
1 parent f5e96ed commit b3eda8f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "firebase-php/google-auth",
"type": "library",
"description": "Google Auth Library for PHP",
"keywords": ["google", "oauth2", "authentication"],
"homepage": "http://github.com/google/google-auth-library-php",
"description": "A fork of Google Auth Library used in Firebase PHP project",
"keywords": ["google", "oauth2", "authentication", "firebase-php"],
"homepage": "http://github.com/firebase-php/google-auth",
"license": "Apache-2.0",
"require": {
"php": ">=5.4",
Expand Down
11 changes: 11 additions & 0 deletions src/Credentials/ServiceAccountCredentials.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ class ServiceAccountCredentials extends CredentialsLoader implements SignBlobInt
*/
protected $auth;

/**
* @var string|null
*/
private $projectId;

/**
* Create a new ServiceAccountCredentials.
*
Expand Down Expand Up @@ -98,6 +103,7 @@ public function __construct(
throw new \InvalidArgumentException(
'json key is missing the private_key field');
}
$this->projectId = isset($jsonKey['project_id']) ? $jsonKey['project_id'] : null;
$this->auth = new OAuth2([
'audience' => self::TOKEN_CREDENTIAL_URI,
'issuer' => $jsonKey['client_email'],
Expand Down Expand Up @@ -195,4 +201,9 @@ public function getClientName(callable $httpHandler = null)
{
return $this->auth->getIssuer();
}

public function getProjectId()
{
return $this->projectId;
}
}

0 comments on commit b3eda8f

Please sign in to comment.