-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Obtain initial access_token if necessary in BatchHttpRequest.execute() #232
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
Obtain initial access_token if necessary in BatchHttpRequest.execute() #232
Conversation
Thanks for your contribution. Can you add tests to cover this case? |
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
I've implemented a test. Writing it actually made me realize that the fix is not exactly ideal, since different type of |
CLAs look good, thanks! |
@@ -1394,6 +1394,15 @@ def execute(self, http=None): | |||
if http is None: | |||
raise ValueError("Missing a valid http object.") | |||
|
|||
# Special case for OAuth2Credentials-style objects which have not yet been | |||
# refreshed with an initial access_token. | |||
if http is not None and hasattr(http.request, 'credentials'): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Please squash commits - there's no need for "Revert local testing changes." to be part of canonical project history. |
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. |
CLAs look good, thanks! |
@nathanielmanistaatgoogle we can do that when we merge now. :) |
One last small request: please edit your commit log message to conform to these guidelines. |
Batch request serialization requires the credentials in the http object to be applied to every individual request *prior* to actually invoking http.request(). This circumvents the self-refresh logic in the request() function monkey-patched by the OAuth2 credentials, thus resulting in the use of an uninitialized credentials object. The fix here is to detect when OAuth2-like credentials are being used and to force a refresh in case the access token is not initialized yet. Resolves: #211
I've updated the commit message to adhere to the guidelines. |
Thank you for your contribution! |
Thank you ! Learned a few things (: |
Adding license header to __init__.py.
Fixes #211