File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -77,14 +77,19 @@ def get_access_token(self) -> str:
7777 self ._refresh_token = tokens ["refresh_token" ]
7878 self ._access_token_expiry = tokens ["expires_at" ]
7979 # If we have a token but it's expired, we need to refresh it
80+ # We refresh the token if it's expired or if it's about to expire in less than 3 minutes
8081 elif self ._access_token_expiry is None or self ._access_token_expiry < int (
81- datetime .now (UTC ).timestamp (),
82+ datetime .now (UTC ).timestamp () - 3 * 60 ,
8283 ):
8384 # Token is expired, we need to refresh it
8485 try :
8586 tokens = self ._auth_client .refresh_token (
8687 refresh_token = self ._refresh_token ,
8788 )
89+ self ._access_token = tokens ["access_token" ]
90+ self ._refresh_token = tokens ["refresh_token" ]
91+ self ._access_token_expiry = tokens ["expires_at" ]
92+ return self .get_access_token ()
8893 except Exception :
8994 hyperion_error_logger .exception (
9095 "Payment: failed to refresh HelloAsso access token, getting a new one" ,
You can’t perform that action at this time.
0 commit comments