Skip to content
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

feat: send quota project id in x-goog-user-project for OAuth2 credentials #412

Merged
merged 6 commits into from
Dec 18, 2019

Conversation

busunkim96
Copy link
Contributor

(Re-adds quota_project_id. Original PR is #400.)

When 3LO credentials are used, the quota project ("quota_project_id") should be sent on every outgoing request in the x-goog-user-project HTTP header/grpc metadata.

New Addition:
google.oauth2.credentials has __setstate__ and __getstate__ methods to properly unpickle objects created with previous library versions.

Samples that use google-api-python-client often pickle the OAuth2 credentials object (examples: 1, 2). Folks had token files that stopped working when they upgraded the library. See issue #405.

I could add __setstate__ and __getstate__ to the base credentials class google.auth.credentials, but I think other types of credentials are less likely to be pickled.

busunkim96 and others added 4 commits December 16, 2019 10:53
…credentials (googleapis#400)

When the 3LO credentials are used, the quota project ("quota_project_id") is sent on every outgoing request in the x-goog-user-project HTTP header/grpc metadata. The quota project is used for billing and quota purposes.
@googlebot googlebot added the cla: yes This human has signed the Contributor License Agreement. label Dec 16, 2019
Copy link
Contributor

@tswast tswast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a unit test with a pickled object from a previous version of the auth library to ensure it loads? Then again, I guess pickle files aren't guaranteed to work across Python versions, right?

Obviously, use a fake client ID, secret, and tokens in that pickle file.

@busunkim96 busunkim96 requested a review from tswast December 18, 2019 00:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants