Hi Guys, Im building a connector where the refres...
# connector-development
m
Hi Guys, Im building a connector where the refresh token changes every time you get a new access token from a refresh token. Is there some way to store the newly generated refresh token? Do you have an example connector that does this available?
t
I saw this ticket: https://github.com/airbytehq/airbyte/issues/3990 do you guys have any update on it?
@Thomas you can overide get_access_token to update new refresh token. It should work for current session. I am not sure if it is stored in state
I dont think it gets stored.
Hi @Thomas, I confirm that you could update the refresh token by overriding
Oauth2Authenticator.get_access_token
and
Oauth2Authenticator.refresh_access_token
methods to retrieve your new refresh token for the API response and update
self.refresh_token
accordingly.
@[DEPRECATED] Augustin Lafanechere After updating refresh token, is it stored in the db as part of the state or config ?
@[DEPRECATED] Augustin Lafanechere if its not stored then it will be a problem incase of incremental updates.
Yes you're right, it'll be a problem. And no, the Authenticator is not interacting with the state so no tokens are stored in the state.
@[DEPRECATED] Augustin Lafanechere Every time you request an access token you will get a new refresh token and the old token gets invalidated. If we cant store the new refresh token we cant make this connector work. Is there any way i can modify the database to store the refresh token from the connector?
This is a major blocker for me at the moment.
Maybe you can hack something up against the current CDK design, updating the state with the latest refresh token each time
get_updated_state
is called. I have no guarantee that this can work sorry 😄 I encourage you to dig a bit into our CDK design and foster the discussion in the issue with suggestions about how supporting single-use refresh tokens could work.
hi @[DEPRECATED] Augustin Lafanechere We have looked in the CDK design and noticed that state is being kept per stream. Oauth Refresh tokes work for the entire source. We need a method to update the state of the source and not of the stream.
Create a dummy
state
stream and store the state for it.
I'm sorry you encountered a dead end while investigating this in the CDK. I think that at the moment your best bet is to try to store the token state yourself in the backend of your choice and make the connector use this backend.
f
Sure I can do that but it defeats the purpose of using airbyte, is there anyone from the airbyte team that can support me with making sure we can use a statefull key inside a connector?