Hi all, I’ve built a custom connector using `Sing...
# help-connector-development
e
Hi all, I’ve built a custom connector using
SingleUseRefreshTokenOauth2Authenticator
and I’m running into an issue where the access token expires within the same sync. Not entirely sure what’s going on!
k
A message from kapa.ai
Based on the information provided in the extracts, it seems like you're dealing with a common issue where the access token expires before the sync operation is completed. This can happen if the access token has a short lifespan and the sync operation takes longer than this lifespan. In such cases, you need to ensure that your connector is set up to automatically refresh the access token when it expires. The
SingleUseRefreshTokenOauth2Authenticator
should handle this for you, but it's possible that there might be an issue with your implementation or the API you're connecting to. Here are a few things you can check: 1. Ensure that your connector is correctly using the
SingleUseRefreshTokenOauth2Authenticator
. This should automatically handle the refreshing of the access token. 2. Check the lifespan of your access token. If it's very short and your sync operations are long, you might need to find a way to extend the lifespan of the token or make your sync operations faster. 3. Check the logs for any errors or issues related to the token refresh process. This might give you more insight into what's going wrong. 4. If the API you're connecting to uses a refresh token that also expires, you might need to implement a custom solution to handle this. One user in a [forum discussion](https://discuss.airbyte.io/t/3275) mentioned a similar issue and ended up using a
SingleUseRefreshTokenOauth2Authenticator
. If you're still having issues, it might be helpful to provide more details about your implementation and the API you're connecting to. This could help identify any specific issues that might be causing your problem.
s
Hi Ethan is this on Airbyte Cloud or OSS?
e
OSS
s
which version? can you share your manifest?
e
@Sherif Nada I’m seeing `401`s returned with a message
jwt expired
from my custom sdk api connector
Not sure the sdk handles retries in that case. I can add a custom
should_retry
but that won’t recreate the authorization header (which would refresh the token)
I believe I’m
0.50.1
and Airbyte-sdk
0.40.5
@Sherif Nada any ideas on how to handle this edge case?
j
it sounds like the authenticator is not handling the expiration time correctly
if everything goes well, the authenticator will never run into the case of the expired access token being used, instead it request a new one in time
Please double-check the expiration time coming from the token refresh endpoint is handled correctly by your connector
e
Thanks @Joe Reuter (Airbyte) what should I be looking for? The endpoint returns an
expired_in
as an int in seconds. What else would I need to do
j
If it's actually
expired_in
in your case, you will need to adjust it
if that doesn't work, try logging debug information to see where things break down for your specific case
e
Ah that would be great - but had a typo my api is returning
expires_in
@Joe Reuter (Airbyte) I ended up adding a 10 minute buffer to the expiry time and that seemed to do the trick! Thanks for your help