Skip to content

Token Refresh in a Multiple Process Environment #71

@walgitrus

Description

@walgitrus

i’m finding an issue when making box sdk requests from a django app which runs with multiple worker processes. the scenario seems to be that one process makes a request which results in token auto-refresh. after this, any other worker process which makes a request will fail due to a now-expired token + expired refresh token.

the exception is
BoxOAuthException:
Message: {"error":"invalid_grant","error_description":"Invalid refresh token"}
Status: 400
URL: https://api.box.com/oauth2/token
Method: POST

the stack trace is
boxsdk/session/box_session.py ? in _retry_request_if_necessary
boxsdk/session/box_session.py ? in _renew_session
boxsdk/auth/oauth2.py ? in refresh
boxsdk/auth/oauth2.py ? in _refresh
boxsdk/auth/oauth2.py ? in send_token_request

one possibility is to add a a pre-refresh callback, similar to the OAuth2._store_tokens callback.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions