Hi, I am buidling a source which uses oauth2 authe...
# help-connector-development
n
Hi, I am buidling a source which uses oauth2 authentication using python CDK(htttp api method). I have an access_token which has 30 days expiry & a refresh_token which get expired once we use it to generate a new access_token & refresh_token. I have tried implemeting with SingleUseRefreshTokenOauth2Authenticator. But I am facing an issue like once the access_token gets expired, the newly generated access_token & refresh_token is not setted properly for the next sync(i.e it is taking the tokens which I have given initially) How could I solve this?
k
A message from kapa.ai
It seems like you're facing an issue with the refresh token not being updated properly after the access token expires. The
SingleUseRefreshTokenOauth2Authenticator
should handle this case, as it's designed for OAuth implementations with single-use refresh tokens. However, it's important to note that the platform needs to handle the
Control
messages emitted by the connector for this to work. There is a PR ([#19811](https://github.com/airbytehq/airbyte/pull/19811)) that aims to update the actor configuration when receiving control messages from connectors during sync. Once this PR is merged and the platform handles the
Control
messages, the issue should be resolved. In the meantime, you can refer to this [forum discussion](https://discuss.airbyte.io/t/3275) where a user faced a similar issue and managed to solve it with the help of the
SingleUseRefreshTokenOauth2Authenticator
. If you still face issues, please share more details about your implementation or any error messages you encounter, so we can provide more specific guidance.
j
Are you facing this issue during regular syncs or somehow during testing?
The way the single use refresh token authenticator works is that it will update its own configuration with the response from the token refresh endpoint which has to include a new refresh token under the configured property in the response object
Also make sure the token expiry time is set to the correct value (this is what the connector uses to determine whether its access token is expired)
n
I faced this issue while building custom connector.
and testing it
The token is getting refreshed & gets updated for the current sync which is happening
But for the next sync, The refreshed new access token is not used
The issue seems like the newly fetched access & refresh token is not stored in something like state for next sync
j
it should be stored in the configuration of the connector
Can you share the source code for your custom connector?
The important part is that
refresh_token_config_path
and
refresh_token_name
https://github.com/airbytehq/airbyte/blob/67c4f6c7fa5a2ec7eb275ca3da97d97cbc8ea059[…]/airbyte_cdk/sources/streams/http/requests_native_auth/oauth.py are configured correctly