Skip to content

Commit

Permalink
fix: correct variable name and credential copying (GoogleCloudPlatfor…
Browse files Browse the repository at this point in the history
…m#25)

* fix: variable named incorrectly

* fix: reduce auth init to not create credential copies, just provide scopes at time of default creation

* chore: blacken
  • Loading branch information
crwilcox authored Mar 31, 2020
1 parent 5b02e80 commit 41e317e
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions google/cloud/sql/connector/InstanceConnectionManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 41e317e

Please sign in to comment.