I am building a connector for a source that does n...
# connector-development
w
I am building a connector for a source that does not support refresh tokens, so when the current token expires you have to log in with basic auth again. I have overwritten the `should_retry` method to reset `self._session.auth` on 401 errors and return `True`. The initial login is working and based on the logs the request is getting retried, but it seems like the new login is not being applied. Any ideas where I am going wrong?
a
Hi @Will Watkinson, I think you should instantiate your streams with the TokenAuthenticator returned by your
client.login()
. The request auth headers are set in
HttpStream.read_records
and are retrieved using
self.authenticator.get_auth_header()
. In your context I think
self.authenticator == NoAuth()
because you did not pass an authenticator in to your streams in your kwargs.
w
Thanks! I just got it working. The issue was that resetting
self._session.auth
like
HttpStream
did in
__init__
did not reset the auth headers on the specific request that was getting retried. Explicitly setting
response.request.headers["Authorization"]
with the new token fixed that, though. https://github.com/wjwatkinson/airbyte/blob/source-kyriba/airbyte-integrations/connectors/source-kyriba/source_kyriba/source.py#L70