FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Adding scope to credentials in Connection constructors. by dhermes · Pull Request #840 · googleapis/google-cloud-python · GitHub

Adding scope to credentials in Connection constructors. - #840

Merged
dhermes merged 1 commit into
googleapis:masterfrom
dhermes:create-scoped-help
May 14, 2015
Merged

Adding scope to credentials in Connection constructors.#840
dhermes merged 1 commit into
googleapis:masterfrom
dhermes:create-scoped-help

Conversation

dhermes commented Apr 19, 2015

Copy link
Copy Markdown
Contributor

This also obsoletes get_scoped_connection() so it is removed.

FYI @jgeewax thanks for nudging in this direction. It moves the scope adding behavior into the Connection constructors.

googlebot added the cla: yes This human has signed the Contributor License Agreement. label Apr 19, 2015

Copy link
Copy Markdown

Coverage remained the same at 100.0% when pulling 0cb6fc9 on dhermes:create-scoped-help into 286207b on GoogleCloudPlatform:master.

tseaver commented Apr 23, 2015

Copy link
Copy Markdown
Contributor

I might be misremembering, but it feels like we've been around a complete circle here.

dhermes commented Apr 23, 2015

Copy link
Copy Markdown
Contributor Author

What's the circle? I don't recall the Connection constructors adding scope, but maybe it happened? AFAIK I am the only "resident expert" when it comes to oauth2client.

tseaver commented Apr 23, 2015

Copy link
Copy Markdown
Contributor

6ebc65e moved the scope handling from gcloud.datastore._implicit_environ.get_connection and gcloud.storage._implicit_environ.get_connection up to gcloud._helpers.get_scoped_connection
5588987 moved the function from gcloud._helpers to gcloud.connection.
Now we are pushing the scope handling back down into gcloud.datastore.connection and gcloud.storage.connection.

dhermes commented Apr 23, 2015

Copy link
Copy Markdown
Contributor Author

The idea behind this commit is not just churn / moving the code.

We want people to be able to get credentials from elsewhere and pass them in to a connection without worrying about adding the scopes.

If we never expect people to construct a Connection themselves, then this PR is totally moot, but we'd still need to add credentials to the get_connection() methods to allow people a BYOC (bring your own credentials).


This was all brought about by @jgeewax pointing out some alternate auth / credentials flows.

dhermes commented Apr 27, 2015

Copy link
Copy Markdown
Contributor Author

@tseaver Can we keep moving on this?

Comment thread gcloud/connection.py Outdated

This comment was marked as spam.

This comment was marked as spam.

jgeewax commented Apr 29, 2015

Copy link
Copy Markdown
Contributor

If I recall correctly, the difference this makes becomes apparent when you look at the case where you want to use some credentials from a specific file to talk to a service.

Old way:

from gcloud.credentials import get_for_service_account_json
from gcloud import pubsub

credentials = get_for_service_account_json('/path/to/key.json')
credentials = credentials.create_scoped(pubsub.SCOPE)  # <-- The thing I don't want to have to type...
connection = pubsub.Connection(credentials=credentials)
pubsub.set_default_connection(connection)
pubsub.Topic('topic_name').create()

(Also note that in gcloud.datastore SCOPE was inside _implicit_environ which made the code much less readable....)

New way

from gcloud.credentials import get_for_service_account_json
from gcloud import pubsub

credentials = get_for_service_account_json('/path/to/key.json')
connection = pubsub.Connection(credentials=credentials)  # Scoping happens here, where we know we need it...
pubsub.set_default_connection(connection)
pubsub.Topic('topic_name').create()

Is there a reason why you'd want to keep the "scope credentials" action separate from the "create connection" action? I can't think of a reason but maybe you guys know more about this... If there isn't then I fully support this change -- seems much more convenient to do this when creating the connection (and expecting the connection to know which scopes are necessary on the credentials you supplied).

dhermes commented Apr 29, 2015

Copy link
Copy Markdown
Contributor Author

I also fully support this change FWIW

dhermes commented Apr 30, 2015

Copy link
Copy Markdown
Contributor Author

@tseaver PTAL

Comment thread gcloud/connection.py

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

dhermes force-pushed the create-scoped-help branch from 0cb6fc9 to 7cfc884 Compare May 7, 2015 23:29

dhermes commented May 7, 2015

Copy link
Copy Markdown
Contributor Author

Just rebased on top of HEAD in master.

@tseaver Can we resolve the discussion and move forward here?

Copy link
Copy Markdown

Coverage remained the same at 100.0% when pulling 7cfc884 on dhermes:create-scoped-help into a9bc7fe on GoogleCloudPlatform:master.

dhermes commented May 12, 2015

Copy link
Copy Markdown
Contributor Author

@tseaver Can we wrap this up?

This comment was marked as spam.

tseaver commented May 14, 2015

Copy link
Copy Markdown
Contributor

LGTM, module my comments this morning on the SCOPE docstrings.

This also obsoletes get_scoped_connection() so it is removed.
dhermes force-pushed the create-scoped-help branch from 7cfc884 to b44b25b Compare May 14, 2015 18:36

dhermes commented May 14, 2015

Copy link
Copy Markdown
Contributor Author

Rebased on top of master (#879 #881 in particular) and added the docstrings into the original PR. Will merge when Travis finishes.

dhermes added a commit that referenced this pull request May 14, 2015
Adding scope to credentials in Connection constructors.
dhermes merged commit a888f64 into googleapis:master May 14, 2015
dhermes deleted the create-scoped-help branch May 14, 2015 18:46
parthea pushed a commit that referenced this pull request Nov 24, 2025
Source-Link: googleapis/synthtool@5f2a608
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:8555f0e37e6261408f792bfd6635102d2da5ad73f8f09bcb24f25e6afb5fac97

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this pull request Nov 24, 2025
* chore: create flakybot.yaml to change default issue priority

* add googlel copyright license

---------

Co-authored-by: cindy-peng <cindypeng@google.com>
parthea pushed a commit that referenced this pull request Nov 24, 2025
Source-Link: googleapis/synthtool@fac8444
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:5ea6d0ab82c956b50962f91d94e206d3921537ae5fe1549ec5326381d8905cfa

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this pull request Nov 25, 2025
Source-Link: googleapis/synthtool@fac8444
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:5ea6d0ab82c956b50962f91d94e206d3921537ae5fe1549ec5326381d8905cfa

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this pull request Nov 26, 2025
* chore: release 2.0.0

* Update CHANGELOG.md

* chore: set version number to 2.0.0

Follow up to #829

Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this pull request Mar 6, 2026
* test: refactor `list_rows` tests and add test for scalars

* WIP: INTERVAL support

* feat: add support for INTERVAL data type to `list_rows`

* fix relativedelta construction for non-microseconds

* WIP: support INTERVAL query params

* remove dead code

* INTERVAL not supported in query parameters

* revert query parameter changes

* add validation error for interval

* add unit tests for extreme intervals

* add dateutil to intersphinx

* use dictionary for intersphinx

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* add test case for trailing .

* explicit none

* 🦉 Updates from OwlBot

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* truncate nanoseconds

* use \d group for digits

* use \d for consistency

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: Peter Lamut <plamut@users.noreply.github.com>
parthea pushed a commit that referenced this pull request Mar 6, 2026
Source-Link: googleapis/synthtool@d52e638
Post-Processor: gcr.io/cloud-devrel-public-resources/owlbot-python:latest@sha256:4f9b3b106ad0beafc2c8a415e3f62c1a0cc23cabea115dbe841b848f581cfe99

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
parthea pushed a commit that referenced this pull request Mar 9, 2026
This PR contains the following updates:

| Package | Change |
[Age](https://docs.renovatebot.com/merge-confidence/) |
[Confidence](https://docs.renovatebot.com/merge-confidence/) |
|---|---|---|---|
| cachetools | `==6.2.6` → `==7.0.2` |
![age](https://developer.mend.io/api/mc/badges/age/pypi/cachetools/7.0.2?slim=true)
|
![confidence](https://developer.mend.io/api/mc/badges/confidence/pypi/cachetools/6.2.6/7.0.2?slim=true)
|

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/googleapis/python-spanner-sqlalchemy).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My40OC4xIiwidXBkYXRlZEluVmVyIjoiNDMuNDguMSIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOltdfQ==-->
parthea pushed a commit that referenced this pull request Mar 9, 2026
This adds a flag `preserve_generation` to the method `bucket.delete_blobs()`
- allows preserving and propagating blob generations when set to True (default False)
- better ensures backwards compatibility with both `delete_blobs()` and `bucket.delete(force=True)`

Fixes #814
parthea pushed a commit that referenced this pull request Mar 9, 2026
* feat: Inline Begin transction for RW transactions

* ILB with lock for execute update and batch update

* Added lock for execute sql and read method

* fix: lint fix and testcases

* fix: lint

* fix: Set transction id along with resume token

* fix: lint

* fix: test cases

* fix: few more test case for restart on unavailable

* test: Batch update error test case

* fix: lint

* fix: Code review comments

* fix: test cases + lint

* fix: code review comments

* fix: deprecate transactionpingingpool msg

* fix: review comments

Co-authored-by: larkee <31196561+larkee@users.noreply.github.com>

* fix: Apply suggestions from code review

Co-authored-by: larkee <31196561+larkee@users.noreply.github.com>

* fix: review comments

* fix: review comment Update tests/unit/test_session.py

Co-authored-by: larkee <31196561+larkee@users.noreply.github.com>

Co-authored-by: larkee <31196561+larkee@users.noreply.github.com>
parthea pushed a commit that referenced this pull request Mar 9, 2026
This file contains hidden or 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: core auth cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants


Back | FazBrowse Home | New Git URL