-
Notifications
You must be signed in to change notification settings - Fork 202
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
Adjusting token cache format #19
Conversation
b26cec1
to
1f4b0af
Compare
…ehaviors for debugging
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.
return { # Mimic a real response | ||
"access_token": entry["secret"], | ||
"token_type": "Bearer", | ||
"expires_in": entry["expires_on"] - now, | ||
"expires_in": int(expires_in), # OAuth2 specs defines it as int |
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.
int [](start = 34, length = 3)
it seems like expires_in is already an int? Did -now change it to something else? Should that then have been converted to an int?
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.
Good question! It is true that the expires_in
in the original server-side response is an integer. But here in this code path we hit a token in the cache, and then re-calculate a new expires_in
based on its original value and the current time(), which happens to be a float in Python. So we do a Forceful Unobvious Conversion to Keep the Integer Time, at the exact place where it is needed.
@@ -38,13 +38,19 @@ def __init__(self): | |||
def find(self, credential_type, target=None, query=None): | |||
target = target or [] | |||
assert isinstance(target, list), "Invalid parameter type" | |||
target_set = set(target) |
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 target scopes? if yes, do you have a place where you remove dupes?
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.
Yes target
is exactly scope
in Unified Schema's dialect.
The set(...)
method creates a native set object in Python. It automatically deduplicates the 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.
You can install this branch for your testing: