GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: use self-signed jwt for service account by busunkim96 · Pull Request #665 · googleapis/google-auth-library-python

This repository was archived by the owner on Mar 6, 2026. It is now read-only.

Conversation

@busunkim96

@busunkim96 busunkim96 commented Jan 12, 2021 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

https://google.aip.dev/auth/4111
Googlers see this doc for detailed design.

Create a self-signed JWT from the service account credentials when the following conditions are met:

  1. A service account is being used
  2. A scope has not been set by the user. (Enforced by adding a new default_scopes that is separate from scopes).
  3. A target_audience has not been set by the user (not relevant at the moment since no client option for audience exists).
  4. An api_endpoint has not been set by the user (taken care of in the GAPIC client library).

Other Changes:

  • Add default_scopes to all ScopedCredentials. For non-service account credentials, the default_scopes are used when scopes is not set. Otherwise the default_scopes are ignored.

This change is only being made to synchronous credentials and the gRPC transport. The async credentials and other transports will be handled in follow up PRs.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
busunkim96 added 2 commits January 12, 2021 18:07
@busunkim96
feat: use self-signed jwt for service account
17b72e1
@busunkim96
chore: remove docs changes
891ea31
@google-cla google-cla Bot added the cla: yes This human has signed the Contributor License Agreement. label Jan 12, 2021
busunkim96
busunkim96 commented Jan 12, 2021
View reviewed changes
Comment thread google/auth/credentials.py

@abc.abstractmethod
def with_scopes(self, scopes):
def with_scopes(self, scopes, default_scopes=None):

@busunkim96 busunkim96 Jan 12, 2021

Copy link
Copy Markdown
Contributor Author

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.

Is adding an additional optional parameter to an abstract method a breaking change?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@arithmetic1728 arithmetic1728 Jan 17, 2021

Copy link
Copy Markdown
Contributor

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.

It seems fine.
https://stackoverflow.com/questions/42778784/abstract-classes-with-varying-amounts-of-parameters

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
busunkim96 and others added 2 commits January 14, 2021 20:25
@busunkim96
fix: fix for 2.7
12a7437
@busunkim96
Merge branch 'master' into self-signed-jwt
2db9b5b
@busunkim96 busunkim96 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jan 14, 2021
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jan 14, 2021
@busunkim96
busunkim96 requested review from arithmetic1728, bshaffer and tseaver January 15, 2021 19:38
@busunkim96
busunkim96 marked this pull request as ready for review January 15, 2021 19:39
@busunkim96
busunkim96 requested a review from a team January 15, 2021 19:39
arithmetic1728
arithmetic1728 approved these changes Jan 17, 2021
View reviewed changes

@arithmetic1728 arithmetic1728 left a comment

Copy link
Copy Markdown
Contributor

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.

LGTM

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
bshaffer
bshaffer reviewed Jan 19, 2021
View reviewed changes

@bshaffer bshaffer left a comment

Copy link
Copy Markdown
Contributor

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.

One nit, otherwise this is great

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread google/auth/transport/grpc.py Resolved

Uh oh!

There was an error while loading. Please reload this page.

busunkim96 added 2 commits January 19, 2021 21:48
@busunkim96
fix: use 'default_host' instead of 'audience'
dd0c6f3
@busunkim96
Merge branch 'self-signed-jwt' of github.com:googleapis/google-auth-l…
a5a72b5
…ibrary-python into self-signed-jwt
@busunkim96 busunkim96 mentioned this pull request Jan 20, 2021
feat: allow default_host and default_scopes to be passed to create_channel googleapis/python-api-core#134
Merged
bshaffer
bshaffer approved these changes Jan 20, 2021
View reviewed changes
@busunkim96
fix: audience ends with trailing slash
ed68dc5
@busunkim96 busunkim96 added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jan 21, 2021
@busunkim96
test: run system tests
e425e81
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Jan 21, 2021
busunkim96 added 6 commits January 21, 2021 23:44
@busunkim96
test: decrypt secrets
1fb684c
@busunkim96
test: add secrets tar
4a52bd2
@busunkim96
test: more fixes to config
6a556ca
@busunkim96
test: fix gfile_resources in presubmit config
f3399d7
@busunkim96
test: project-id.txt
96915f9
@busunkim96
chore: properly exclude config files in synth
d46592e
@busunkim96

busunkim96 commented Jan 22, 2021

Copy link
Copy Markdown
Contributor Author

Looks like I accidentally removed the system tests from the presubmit last year 🤦‍♀️ . I was hoping it would be a small fix but it looks like some issues have piled up. I'll pull those changes into a separate PR and revisit this one later.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

busunkim96 added 3 commits January 22, 2021 01:24
@busunkim96
test: fix conftest, async tests
98d3a43
@busunkim96
test: update secrets, import mock
59c4416
@busunkim96
test: fix more system tests
b7adf59
@busunkim96 busunkim96 mentioned this pull request Jan 22, 2021
test: re-enable system tests #670
Merged
busunkim96 added 2 commits January 22, 2021 13:44
@busunkim96
Merge branch 'master' into self-signed-jwt
7bfbd9f
@busunkim96
Merge branch 'master' into self-signed-jwt
5be177f
@busunkim96 busunkim96 added the automerge Merge the pull request once unit tests and other checks pass. label Feb 1, 2021
@busunkim96
busunkim96 merged commit bf5ce0c into master Feb 1, 2021
@busunkim96
busunkim96 deleted the self-signed-jwt branch February 1, 2021 22:17
@gcf-merge-on-green gcf-merge-on-green Bot removed the automerge Merge the pull request once unit tests and other checks pass. label Feb 1, 2021
This was referenced Feb 3, 2021
feat: support self-signed jwt in requests and urllib3 transports #679
Merged
Add self-signed JWT support to async credentials googleapis/google-cloud-python#15219
Closed
@larkee larkee mentioned this pull request Feb 5, 2021
test: fix credential scope assertions googleapis/python-spanner#223
Merged
gcf-merge-on-green Bot pushed a commit to googleapis/python-spanner that referenced this pull request Feb 5, 2021
@larkee
test: fix credential scope assertions (#223)
05c3ad9
The assertions for credential scope in the `client` unit tests were broken by [a PR in the auth library](googleapis/google-auth-library-python#665). This does raise the question of whether we should be asserting the scopes like this in this library.

This PR fixes the assertions. Removal of these assertions can be done in a separate PR if it is decided they don't belong in this library.
@busunkim96 busunkim96 mentioned this pull request Feb 24, 2021
feat: support self-signed JWT flow for service accounts googleapis/gapic-generator-python#774
Merged
busunkim96 added a commit to googleapis/gapic-generator-python that referenced this pull request Apr 21, 2021
@busunkim96 @bshaffer
feat: support self-signed JWT flow for service accounts (#774)
89d6f35
See [RFC (internal only)](https://docs.google.com/document/d/1SNCVTmW6Rtr__u-_V7nsT9PhSzjj1z0P9fAD3YUgRoc/edit#) and https://aip.dev/auth/4111.

Support the self-signed JWT flow for service accounts by passing `default_scopes` and `default_host` in calls to the auth library and `create_channel`. This depends on features exposed in the following PRs: googleapis/python-api-core#134, googleapis/google-auth-library-python#665.

It may be easier to look at https://github.com/googleapis/python-translate/pull/107/files for a diff on a real library.

This change is written so that the library is (temporarily) compatible with older `google-api-core` and `google-auth` versions. Because of this it not possible to reach 100% coverage on a single unit test run. `pytest` runs twice in two of the `nox` sessions.

Miscellaneous changes:
- sprinkled in `__init__.py` files in subdirs of the `test/` directory, as otherwise pytest-cov seems to fail to collect coverage properly in some instances.
- new dependency on `packaging` for Version comparison https://pypi.org/project/packaging/

Co-authored-by: Brent Shaffer <[email protected]>
parthea pushed a commit to googleapis/google-cloud-python that referenced this pull request Nov 24, 2025
@busunkim96 @bshaffer
feat: support self-signed JWT flow for service accounts (#774)
63366ca
See [RFC (internal only)](https://docs.google.com/document/d/1SNCVTmW6Rtr__u-_V7nsT9PhSzjj1z0P9fAD3YUgRoc/edit#) and https://aip.dev/auth/4111.

Support the self-signed JWT flow for service accounts by passing `default_scopes` and `default_host` in calls to the auth library and `create_channel`. This depends on features exposed in the following PRs: googleapis/python-api-core#134, googleapis/google-auth-library-python#665.

It may be easier to look at https://github.com/googleapis/python-translate/pull/107/files for a diff on a real library.

This change is written so that the library is (temporarily) compatible with older `google-api-core` and `google-auth` versions. Because of this it not possible to reach 100% coverage on a single unit test run. `pytest` runs twice in two of the `nox` sessions.

Miscellaneous changes:
- sprinkled in `__init__.py` files in subdirs of the `test/` directory, as otherwise pytest-cov seems to fail to collect coverage properly in some instances.
- new dependency on `packaging` for Version comparison https://pypi.org/project/packaging/

Co-authored-by: Brent Shaffer <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@tseaver tseaver Awaiting requested review from tseaver
2 more reviewers
@arithmetic1728 arithmetic1728 arithmetic1728 approved these changes
@bshaffer bshaffer bshaffer approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

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

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@busunkim96 @bshaffer @arithmetic1728 @yoshi-kokoro
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.