You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CooperativelyManagedOAuth2Mixin overrides _get_tokens(). When refresh() or revoke() are called, this protected method is called to get the latest tokens. However, the access_token property (used by BoxSession for all API requests) still uses the cached _access_token attribute.
During normal usage, this means that, after another instance has done a refresh, the BoxSession will usually make one API call with expired tokens before grabbing the updated tokens.
This makes sense as a default behavior. If the cooperative auth is happening over a network, then the cost of one extra API call per hour is much less than checking for new tokens for every single API call.
But if the cooperation is happening within a process and the mechanism is low-cost, it may be more economical to override the access_token property to always call _get_and_update_current_tokens() before returning the _access_token attribute.
This can be done with a CooperativelyManagedOAuth2Mixin subclass, or an __init__ parameter to toggle the behavior.
There's also the question of whether this is useful functionality to add to the SDK.
The text was updated successfully, but these errors were encountered:
CooperativelyManagedOAuth2Mixin
overrides_get_tokens()
. Whenrefresh()
orrevoke()
are called, this protected method is called to get the latest tokens. However, theaccess_token
property (used byBoxSession
for all API requests) still uses the cached_access_token
attribute.During normal usage, this means that, after another instance has done a refresh, the
BoxSession
will usually make one API call with expired tokens before grabbing the updated tokens.This makes sense as a default behavior. If the cooperative auth is happening over a network, then the cost of one extra API call per hour is much less than checking for new tokens for every single API call.
But if the cooperation is happening within a process and the mechanism is low-cost, it may be more economical to override the
access_token
property to always call_get_and_update_current_tokens()
before returning the_access_token
attribute.This can be done with a
CooperativelyManagedOAuth2Mixin
subclass, or an__init__
parameter to toggle the behavior.There's also the question of whether this is useful functionality to add to the SDK.
The text was updated successfully, but these errors were encountered: