New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(db_api): allow file path for credentials #221
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
45ad56e
fix: credentials_uri parameter error
HemangChothani b830c65
fix: combine credentials and credentials_uri
HemangChothani 5506db4
Merge branch 'master' of https://github.com/googleapis/python-spanner…
HemangChothani 2044ce8
fix: nits
HemangChothani 6da206c
Merge branch 'master' of https://github.com/googleapis/python-spanner…
HemangChothani File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -356,7 +356,9 @@ def connect( | |
:type credentials: :class:`~google.auth.credentials.Credentials` | ||
:param credentials: (Optional) The authorization credentials to attach to | ||
requests. These credentials identify this application | ||
to the service. If none are specified, the client will | ||
to the service. Or a string specifying (path) where to retrieve | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Perhaps:
|
||
the service account JSON for the credentials to connect to | ||
Cloud Spanner.If none are specified, the client will | ||
attempt to ascertain the credentials from the | ||
environment. | ||
|
||
|
@@ -380,9 +382,14 @@ def connect( | |
user_agent=user_agent or DEFAULT_USER_AGENT, python_version=PY_VERSION | ||
) | ||
|
||
client = spanner.Client( | ||
project=project, credentials=credentials, client_info=client_info | ||
) | ||
if isinstance(credentials, str): | ||
client = spanner.Client.from_service_account_json( | ||
credentials, project=project, client_info=client_info | ||
) | ||
else: | ||
client = spanner.Client( | ||
project=project, credentials=credentials, client_info=client_info | ||
) | ||
|
||
instance = client.instance(instance_id) | ||
if not instance.exists(): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.