From 41e317ecdf6131d933ee455cd68fc4006aac8584 Mon Sep 17 00:00:00 2001 From: Christopher Wilcox Date: Tue, 31 Mar 2020 16:12:41 -0700 Subject: [PATCH] fix: correct variable name and credential copying (#25) * fix: variable named incorrectly * fix: reduce auth init to not create credential copies, just provide scopes at time of default creation * chore: blacken --- google/cloud/sql/connector/InstanceConnectionManager.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/google/cloud/sql/connector/InstanceConnectionManager.py b/google/cloud/sql/connector/InstanceConnectionManager.py index 1174ed84..77a00f2d 100644 --- a/google/cloud/sql/connector/InstanceConnectionManager.py +++ b/google/cloud/sql/connector/InstanceConnectionManager.py @@ -67,7 +67,7 @@ def __init__( # files to be compatible with Windows. self._ca_fileobject.write(server_ca_cert.encode()) self._cert_fileobject.write(ephemeral_cert.encode()) - self.key_fileobject.write(private_key) + self._key_fileobject.write(private_key) self._ca_fileobject.seek(0) self._cert_fileobject.seek(0) @@ -371,15 +371,14 @@ def _auth_init(self) -> None: Google Cloud SQL Admin API. """ - credentials, project = google.auth.default() - scoped_credentials = credentials.with_scopes( - [ + credentials, project = google.auth.default( + scopes=[ "https://www.googleapis.com/auth/sqlservice.admin", "https://www.googleapis.com/auth/cloud-platform", ] ) - self._credentials = scoped_credentials + self._credentials = credentials def _perform_refresh(self) -> concurrent.futures.Future: """Retrieves instance metadata and ephemeral certificate from the