refactor: split 'with_quota_project' into separate base class (#561)
Co-authored-by: Tres Seaver <tseaver@palladion.com>
diff --git a/google/oauth2/credentials.py b/google/oauth2/credentials.py
index 6f96275..6e58f63 100644
--- a/google/oauth2/credentials.py
+++ b/google/oauth2/credentials.py
@@ -47,7 +47,7 @@
_GOOGLE_OAUTH2_TOKEN_ENDPOINT = "https://oauth2.googleapis.com/token"
-class Credentials(credentials.ReadOnlyScoped, credentials.Credentials):
+class Credentials(credentials.ReadOnlyScoped, credentials.CredentialsWithQuotaProject):
"""Credentials using OAuth 2.0 access and refresh tokens.
The credentials are considered immutable. If you want to modify the
@@ -161,7 +161,7 @@
the initial token is requested and can not be changed."""
return False
- @_helpers.copy_docstring(credentials.Credentials)
+ @_helpers.copy_docstring(credentials.CredentialsWithQuotaProject)
def with_quota_project(self, quota_project_id):
return self.__class__(
@@ -305,7 +305,7 @@
return json.dumps(prep)
-class UserAccessTokenCredentials(credentials.Credentials):
+class UserAccessTokenCredentials(credentials.CredentialsWithQuotaProject):
"""Access token credentials for user account.
Obtain the access token for a given user account or the current active
@@ -336,7 +336,7 @@
"""
return self.__class__(account=account, quota_project_id=self._quota_project_id)
- @_helpers.copy_docstring(credentials.Credentials)
+ @_helpers.copy_docstring(credentials.CredentialsWithQuotaProject)
def with_quota_project(self, quota_project_id):
return self.__class__(account=self._account, quota_project_id=quota_project_id)
diff --git a/google/oauth2/service_account.py b/google/oauth2/service_account.py
index 2240631..c4898a2 100644
--- a/google/oauth2/service_account.py
+++ b/google/oauth2/service_account.py
@@ -82,7 +82,9 @@
_DEFAULT_TOKEN_LIFETIME_SECS = 3600 # 1 hour in seconds
-class Credentials(credentials.Signing, credentials.Scoped, credentials.Credentials):
+class Credentials(
+ credentials.Signing, credentials.Scoped, credentials.CredentialsWithQuotaProject
+):
"""Service account credentials
Usually, you'll create these credentials with one of the helper
@@ -306,7 +308,7 @@
additional_claims=new_additional_claims,
)
- @_helpers.copy_docstring(credentials.Credentials)
+ @_helpers.copy_docstring(credentials.CredentialsWithQuotaProject)
def with_quota_project(self, quota_project_id):
return self.__class__(
@@ -375,7 +377,7 @@
return self._service_account_email
-class IDTokenCredentials(credentials.Signing, credentials.Credentials):
+class IDTokenCredentials(credentials.Signing, credentials.CredentialsWithQuotaProject):
"""Open ID Connect ID Token-based service account credentials.
These credentials are largely similar to :class:`.Credentials`, but instead
@@ -533,7 +535,7 @@
quota_project_id=self.quota_project_id,
)
- @_helpers.copy_docstring(credentials.Credentials)
+ @_helpers.copy_docstring(credentials.CredentialsWithQuotaProject)
def with_quota_project(self, quota_project_id):
return self.__class__(
self._signer,