Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
merged 1 commit into from
May 31, 2016

Conversation

Garciat
Copy link
Contributor

@Garciat Garciat commented May 24, 2016

Fixes #211

@theacodes
Copy link
Contributor

Thanks for your contribution. Can you add tests to cover this case?

@googlebot
Copy link
Collaborator

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 signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@googlebot googlebot added the cla: no This human has *not* signed the Contributor License Agreement. label May 25, 2016
@Garciat
Copy link
Contributor Author

Garciat commented May 25, 2016

I've implemented a test. Writing it actually made me realize that the fix is not exactly ideal, since different type of Credentials-derived object may exist which are not access token-based. A more involved fix would require actually providing a method in the base Credentials class akin to is_ready() or whatever.

@googlebot
Copy link
Collaborator

CLAs look good, thanks!

@googlebot googlebot added cla: yes This human has signed the Contributor License Agreement. and removed cla: no This human has *not* signed the Contributor License Agreement. labels May 25, 2016
@@ -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.

@nathanielmanistaatgoogle
Copy link
Contributor

Please squash commits - there's no need for "Revert local testing changes." to be part of canonical project history.

@googlebot
Copy link
Collaborator

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.

@googlebot googlebot added cla: no This human has *not* signed the Contributor License Agreement. and removed cla: yes This human has signed the Contributor License Agreement. labels May 25, 2016
@googlebot
Copy link
Collaborator

CLAs look good, thanks!

@googlebot googlebot added cla: yes This human has signed the Contributor License Agreement. and removed cla: no This human has *not* signed the Contributor License Agreement. labels May 25, 2016
@theacodes
Copy link
Contributor

Please squash commits - there's no need for "Revert local testing changes." to be part of canonical project history.

@nathanielmanistaatgoogle we can do that when we merge now. :)

@nathanielmanistaatgoogle
Copy link
Contributor

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
@Garciat
Copy link
Contributor Author

Garciat commented May 30, 2016

I've updated the commit message to adhere to the guidelines.

@nathanielmanistaatgoogle nathanielmanistaatgoogle merged commit 68bce4e into googleapis:master May 31, 2016
@nathanielmanistaatgoogle
Copy link
Contributor

Thank you for your contribution!

@Garciat Garciat deleted the fix/bug-211 branch May 31, 2016 07:29
@Garciat
Copy link
Contributor Author

Garciat commented May 31, 2016

Thank you ! Learned a few things (:

akrherz pushed a commit to akrherz/google-api-python-client that referenced this pull request Apr 1, 2019
Adding license header to __init__.py.
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.

4 participants