feat: add quota project to base credentials class (#546)
diff --git a/google/auth/app_engine.py b/google/auth/app_engine.py
index ab69951..fae00d0 100644
--- a/google/auth/app_engine.py
+++ b/google/auth/app_engine.py
@@ -84,7 +84,7 @@
tokens.
"""
- def __init__(self, scopes=None, service_account_id=None):
+ def __init__(self, scopes=None, service_account_id=None, quota_project_id=None):
"""
Args:
scopes (Sequence[str]): Scopes to request from the App Identity
@@ -93,6 +93,8 @@
:func:`google.appengine.api.app_identity.get_access_token`.
If not specified, the default application service account
ID will be used.
+ quota_project_id (Optional[str]): The project ID used for quota
+ and billing.
Raises:
EnvironmentError: If the App Engine APIs are unavailable.
@@ -107,6 +109,7 @@
self._scopes = scopes
self._service_account_id = service_account_id
self._signer = Signer()
+ self._quota_project_id = quota_project_id
@_helpers.copy_docstring(credentials.Credentials)
def refresh(self, request):
@@ -137,7 +140,17 @@
@_helpers.copy_docstring(credentials.Scoped)
def with_scopes(self, scopes):
return self.__class__(
- scopes=scopes, service_account_id=self._service_account_id
+ scopes=scopes,
+ service_account_id=self._service_account_id,
+ quota_project_id=self.quota_project_id,
+ )
+
+ @_helpers.copy_docstring(credentials.Credentials)
+ def with_quota_project(self, quota_project_id):
+ return self.__class__(
+ scopes=self._scopes,
+ service_account_id=self._service_account_id,
+ quota_project_id=quota_project_id,
)
@_helpers.copy_docstring(credentials.Signing)