Skip to content

Conversation

@bochunz
Copy link
Contributor

@bochunz bochunz commented Aug 3, 2016

  1. Remove the bogus log messages generated by the old multistore_file module by switching to multiprocess_file_storage module.
  2. Add cache for getting 2LO token by using the same multiprocess_file_storage module.

@coveralls
Copy link

coveralls commented Aug 3, 2016

Coverage Status

Coverage decreased (-0.2%) to 99.624% when pulling 460c516 on bochunz:log into 3b8c369 on google:master.

@craigcitro
Copy link
Contributor

In general, it's better to split these into separate pull requests, since there are two separate things happening.

We also want a longer description:

  1. Mention issues being fixed by number (so that submitting this closes those issues with a reference)
  2. Some details about what's happening in each of the fixes

Someone who comes along in the future will not be able to figure out much based on the description here.

return credentials

def _GetCredentialForServiceAccount(json_keyfile, scopes,
credentials_filename=None):
Copy link
Contributor

Choose a reason for hiding this comment

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

just curious: did this not fit on the line above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no :(

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 99.624% when pulling 02271a9 on bochunz:log into 3b8c369 on google:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 99.623% when pulling a923bd0 on bochunz:log into 3b8c369 on google:master.

@bochunz
Copy link
Contributor Author

bochunz commented Aug 3, 2016

@wora @craigcitro PTAL

@wora
Copy link
Contributor

wora commented Aug 3, 2016

Please bump up the version.

@bochunz
Copy link
Contributor Author

bochunz commented Aug 3, 2016

So we bump up from 0.9.0 --> 0.9.1?

@coveralls
Copy link

coveralls commented Aug 4, 2016

Coverage Status

Coverage decreased (-0.2%) to 99.623% when pulling ab0cecb on bochunz:log into 3b8c369 on google:master.

@craigcitro
Copy link
Contributor

I'm going to get back to this later today -- but do not include a version bump in this PR. It's already got too many things going on. 😉

@bochunz
Copy link
Contributor Author

bochunz commented Aug 4, 2016

Thanks Craig

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 99.623% when pulling f9f8214 on bochunz:log into 3b8c369 on google:master.

credentials_filename = _GetCredentialsFilename(credentials_filename)
storage_key = '3LO-{}-{}-{}'.format(
client_info['client_id'],
client_info['user_agent'],
Copy link
Contributor

Choose a reason for hiding this comment

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

Why add user agent to the key?

Copy link
Contributor Author

@bochunz bochunz Aug 5, 2016

Choose a reason for hiding this comment

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

I thought there are some reason to put user agent so I didn't remove it. Removed.

@wora
Copy link
Contributor

wora commented Aug 5, 2016

If I have a cached token of scopes A,B, should I use it for request that only needs scope A?

@bochunz
Copy link
Contributor Author

bochunz commented Aug 5, 2016

As for the token scope subset problem, I think we should keep it simple. i.e. get token with the exact scopes. Otherwise this tool will have inconsistent outputs: when user ask for token with scope A, he/she may get token with any other scope.

@coveralls
Copy link

coveralls commented Aug 5, 2016

Coverage Status

Coverage decreased (-0.2%) to 99.623% when pulling 9049355 on bochunz:log into 3b8c369 on google:master.

' '.join(sorted(scopes)))
credentials = credential_store.get()
if credentials is None or credentials.invalid:
credentials = service_account.ServiceAccountCredentials \
Copy link
Contributor

Choose a reason for hiding this comment

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

silly: the \ is awkward; if nothing else, you could do

credentials = (
    service_account.ServiceAccountCredentials.form_json_keyfile_dict(

or just make an alias, eg

ServiceAccountCredentials = service_account.ServiceAccountCredentials
credentials = ServiceAccountCredentials.from_json_keyfile_dict(...)

(or some other variation)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@craigcitro
Copy link
Contributor

LGTM

I think you can also tell the coverage tool to not worry with just

 # pragma: NO COVER

which I would say you should go ahead and do here or in a related PR.

@craigcitro
Copy link
Contributor

@wora letting you merge if you're happy with it.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.02%) to 99.811% when pulling 08fb81d on bochunz:log into 3b8c369 on google:master.


def _GetCredentialStore(credentials_filename, key_id, scopes):
credentials_filename = _GetCredentialsFilename(credentials_filename)
storage_key = '{}-{}'.format(key_id, scopes)
Copy link
Contributor

@wora wora Aug 5, 2016

Choose a reason for hiding this comment

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

  • is not very safe. # is better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

_GetCredentialStore takes sorted and joined scopes as one string

Copy link
Contributor Author

@bochunz bochunz Aug 5, 2016

Choose a reason for hiding this comment

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

import oauth2client.contrib.multiprocess_file_storage
import oauth2client.service_account
import oauth2client.tools
import six
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we get dependency on six?

@wora
Copy link
Contributor

wora commented Aug 5, 2016

Couple of minor questions.

1. Remove the bogus log messages generated by the old multistore_file
module by switching to multiprocess_file_storage module.
2. Add cache for getting 2LO token by using the same
multiprocess_file_storage module.
@wora
Copy link
Contributor

wora commented Aug 5, 2016

LGTM

@wora wora merged commit afc56ef into google:master Aug 5, 2016
@coveralls
Copy link

coveralls commented Aug 5, 2016

Coverage Status

Coverage increased (+0.02%) to 99.811% when pulling 2262d7f on bochunz:log into 3b8c369 on google:master.

@bochunz bochunz deleted the log branch August 24, 2016 01:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants