feat: add quota_project_id to service accounts; add with_quota_project methods (#519)
Adds quota_project_id to service account credentials, making it possible to set quota_project_id on OAuth2 credentials and service account credentials.
This PR also adds the method with_quota_project to both classes.
diff --git a/tests/oauth2/test_credentials.py b/tests/oauth2/test_credentials.py
index 76aa463..78b1012 100644
--- a/tests/oauth2/test_credentials.py
+++ b/tests/oauth2/test_credentials.py
@@ -323,6 +323,22 @@
creds.apply(headers)
assert "x-goog-user-project" not in headers
+ def test_with_quota_project(self):
+ creds = credentials.Credentials(
+ token="token",
+ refresh_token=self.REFRESH_TOKEN,
+ token_uri=self.TOKEN_URI,
+ client_id=self.CLIENT_ID,
+ client_secret=self.CLIENT_SECRET,
+ quota_project_id="quota-project-123",
+ )
+
+ new_creds = creds.with_quota_project("new-project-456")
+ assert new_creds.quota_project_id == "new-project-456"
+ headers = {}
+ creds.apply(headers)
+ assert "x-goog-user-project" in headers
+
def test_from_authorized_user_info(self):
info = AUTH_USER_INFO.copy()