-
Notifications
You must be signed in to change notification settings - Fork 85
Remove bogus log messages and add cache for 2LO #7
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
Conversation
|
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:
Someone who comes along in the future will not be able to figure out much based on the description here. |
oauth2l/__init__.py
Outdated
| return credentials | ||
|
|
||
| def _GetCredentialForServiceAccount(json_keyfile, scopes, | ||
| credentials_filename=None): |
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.
just curious: did this not fit on the line above?
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.
no :(
|
@wora @craigcitro PTAL |
|
Please bump up the version. |
|
So we bump up from 0.9.0 --> 0.9.1? |
|
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. 😉 |
|
Thanks Craig |
oauth2l/__init__.py
Outdated
| credentials_filename = _GetCredentialsFilename(credentials_filename) | ||
| storage_key = '3LO-{}-{}-{}'.format( | ||
| client_info['client_id'], | ||
| client_info['user_agent'], |
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.
Why add user agent to the key?
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.
I thought there are some reason to put user agent so I didn't remove it. Removed.
|
If I have a cached token of scopes A,B, should I use it for request that only needs scope A? |
|
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. |
oauth2l/__init__.py
Outdated
| ' '.join(sorted(scopes))) | ||
| credentials = credential_store.get() | ||
| if credentials is None or credentials.invalid: | ||
| credentials = service_account.ServiceAccountCredentials \ |
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.
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)
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.
Done
|
LGTM I think you can also tell the coverage tool to not worry with just which I would say you should go ahead and do here or in a related PR. |
|
@wora letting you merge if you're happy with it. |
oauth2l/__init__.py
Outdated
|
|
||
| def _GetCredentialStore(credentials_filename, key_id, scopes): | ||
| credentials_filename = _GetCredentialsFilename(credentials_filename) | ||
| storage_key = '{}-{}'.format(key_id, scopes) |
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 not very safe. # is better.
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.
_GetCredentialStore takes sorted and joined scopes as one string
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.
Actually I took the "-" from this example https://github.com/google/oauth2client/blob/master/oauth2client/contrib/multiprocess_file_storage.py#L60
Changed to #
| import oauth2client.contrib.multiprocess_file_storage | ||
| import oauth2client.service_account | ||
| import oauth2client.tools | ||
| import six |
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.
Can we get dependency on six?
|
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.
|
LGTM |
Uh oh!
There was an error while loading. Please reload this page.