def __call__(self, request):
        """Attach necessary headers to all requests

        Automatically reauthenticate before sending request when nearing token expiration
        """

        # Refresh token if it expires soon
        if pendulum.now() + self._token_expiration_buffer >= self._token_expiration:
            self.authenticate()

        request.headers.update(self._login_headers)

        return request
def __call__ ( self , request ) : if pendulum . now ( ) + self . _token_expiration_buffer >= self . _token_expiration : self . authenticate ( ) request . headers . update ( self . _login_headers ) return request
Attach necessary headers to all requests

        Automatically reauthenticate before sending request when nearing token expiration