Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[source-quickbooks] not working after access token expires #45911

Open
1 task
hakodexte opened this issue Sep 25, 2024 · 11 comments
Open
1 task

[source-quickbooks] not working after access token expires #45911

hakodexte opened this issue Sep 25, 2024 · 11 comments

Comments

@hakodexte
Copy link

Connector Name

source-quickbooks

Connector Version

3.0.3

What step the error happened?

Updating the connector

Relevant information

Added all OAuth 2.0 info
Setup the Token Expiry Date to be 1h after the access token was generated (or closer time to it in the :30 mins intervals it allows)
Initiated sync
Worked flawlessly until access token died (1h)
Received 401 error.

I tried both prod and sandbox, same error. I would appreciate your assistance a lot, thank you very much!

Relevant log output

Configuration check failed
'Unable to connect to stream accounts - 401 Client Error: Unauthorized for url: https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer'

Contribute

  • Yes, I want to contribute
@charles-astrafy
Copy link

Same issue here. It seems the mechanism to refresh the token is not working

@marcosmarxm marcosmarxm changed the title Quickbooks connector not working after access token expires [source-quickbooks] not working after access token expires Sep 27, 2024
@marcosmarxm
Copy link
Member

@pabloescoder are you working in other issue related to Quickbooks? Can you take a look into this one?

@pabloescoder
Copy link
Collaborator

@marcosmarxm I've made changes for the other issue and raised a PR, waiting for that to get merged because after those changes the refresh logic is working locally for me, there's an issue with the regression tests which is a blocker. Once that's resolved and that PR is merged, this should ideally be solved.
If it's not resolved even after that, then I'll definitely take a look into what is going wrong.

@tomsweeting
Copy link

Originally posted this here but I think I posed to the wrong thread, so adding it here for visibility.

I have encountered this same issue using latest versions (Arbyte 1.3.0 + Quickbooks Connector 3.0.26)

The initial sync works fine, however after 1 hour once the initial token expires, the sync fails with error: Failure in source: Unauthorized. Please ensure you are authenticated correctly.

Steps taken to replicate the issue this morning:

  • Generated new tokens ~ 10:30AM
  • Ran three manual syncs within the hour, all succeeded
  • Set up cron schedule
  • On first schedule trigger at 12:01PM the connection no longer works
Image

@pabloescoder
Copy link
Collaborator

Hey @tomsweeting
We just released a new version of QB (v4.0.0) with the fix.
It's a major version upgrade because the credentials object was removed from the config and all the config fields were moved to the root level so you might need to repopulate the config fields.
TLDR: QB v4.0.0 solves this issue!

@niteshsharoff
Copy link

I am (extremely) proud to say this synced on it's own for me today in Cloud! Quickbooks finally works automatically! 🥳

@tomsweeting
Copy link

Hey @pabloescoder thanks for the heads-up - that's exciting news! I will try upgrading to 4.0.0 tomorrow to test it out.

@chase-allenops
Copy link

@tomsweeting did you get it working? I'm still running an old version of the QB connector and it recently started failing.

@tomsweeting
Copy link

tomsweeting commented Jan 30, 2025

@chase-allenops I upgraded to QB connector 4.0.0 (and Airbyte 1.4.0) and the token refresh is working for me now.

There is a caveat I have experienced though: It appears mid-sync auth token expiration is not handled gracefully, and will cause the sync to fail. When testing using the Airbyte internal scheduler set to hourly cron, I was seeing ~25% failure rate. Fortunately it does always recover on the next run with no manual intervention.

I have not had any time to dig into why this happens, but I suspect it's not the fault of the QB connector itself since it uses that low-code API.

In the final setup i'm using Airflow to trigger the sync, so putting a single retry works great and keeps the data on-schedule!

@chase-allenops
Copy link

@tomsweeting thanks for the in-depth response. Sounds like I need to bite the bullet and write my own QBO extractor.

@kevinbretthauer
Copy link

I was experiencing the 24 hours that was fixed by 4.0. As of March 12th, I am experiencing a similar error again. I can get the system to sync if I manually refresh the authentication token in the QBO developer playground and then put it into airbye each day.

Below is the log from the error I get if I do not manually replace the authentication token. Appreciate any advice.

2025-03-14 10:35:45 info
2025-03-14 10:35:45 info ----- START CHECK -----
2025-03-14 10:35:45 info
2025-03-14 10:35:50 info Connector exited, processing output
2025-03-14 10:35:50 info Output file jobOutput.json found
2025-03-14 10:35:50 info Connector exited with exit code 0
2025-03-14 10:35:50 info Reading messages from protocol version 0.2.0
2025-03-14 10:35:50 error Encountered an error trying to connect to stream accounts. Error:
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/airbyte_cdk/sources/declarative/checks/check_stream.py", line 46, in check_connection
stream_is_available, reason = availability_strategy.check_availability(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/airbyte_cdk/sources/streams/http/availability_strategy.py", line 48, in check_availability
self.get_first_record_for_slice(stream, stream_slice)
File "/usr/local/lib/python3.11/site-packages/airbyte_cdk/sources/streams/availability_strategy.py", line 81, in get_first_record_for_slice
return next(records_for_slice)
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/airbyte_cdk/sources/declarative/declarative_stream.py", line 154, in read_records
yield from self.retriever.read_records(self.get_json_schema(), stream_slice) # type: ignore # records are of the correct type
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/airbyte_cdk/sources/declarative/retrievers/simple_retriever.py", line 457, in read_records
for stream_data in self._read_pages(record_generator, self.state, _slice):
File "/usr/local/lib/python3.11/site-packages/airbyte_cdk/sources/declarative/retrievers/simple_retriever.py", line 354, in _read_pages
response = self._fetch_next_page(stream_state, stream_slice, next_page_token)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/airbyte_cdk/sources/declarative/retrievers/simple_retriever.py", line 310, in _fetch_next_page
return self.requester.send_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/airbyte_cdk/sources/declarative/requesters/http_requester.py", line 411, in send_request
headers=self._request_headers(
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/airbyte_cdk/sources/declarative/requesters/http_requester.py", line 257, in _request_headers
headers = self._get_request_options(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/airbyte_cdk/sources/declarative/requesters/http_requester.py", line 240, in _get_request_options
auth_options_method(),
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/airbyte_cdk/sources/streams/http/requests_native_auth/abstract_oauth.py", line 85, in get_auth_header
token = self.access_token if self._is_access_token_flow else self.get_access_token()
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/airbyte_cdk/sources/streams/http/requests_native_auth/oauth.py", line 347, in get_access_token
self.refresh_access_token()
File "/usr/local/lib/python3.11/site-packages/airbyte_cdk/sources/streams/http/requests_native_auth/oauth.py", line 365, in refresh_access_token
response_json = self._make_handled_request()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/backoff/_sync.py", line 105, in retry
ret = target(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/airbyte_cdk/sources/streams/http/requests_native_auth/abstract_oauth.py", line 214, in _make_handled_request
response.raise_for_status()
File "/usr/local/lib/python3.11/site-packages/requests/models.py", line 1024, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer

2025-03-14 10:35:50 error Check failed
2025-03-14 10:35:50 info Checking for optional control message...
2025-03-14 10:35:50 info Writing output of cf9c4355-b171-4477-8f2d-6c5cc5fc8b7e_9243fea1-152c-4eb1-8c28-f7ba23483deb_0_check to the doc store
2025-03-14 10:35:50 info Marking workload cf9c4355-b171-4477-8f2d-6c5cc5fc8b7e_9243fea1-152c-4eb1-8c28-f7ba23483deb_0_check as successful
2025-03-14 10:35:51 info
2025-03-14 10:35:51 info Deliberately exiting process with code 0.
2025-03-14 10:35:51 info ----- END CHECK -----
2025-03-14 10:35:51 info

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants