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

AuthClient unconditionally makes http request on initialization #18

Open
ryphill opened this issue Jan 13, 2020 · 1 comment
Open

AuthClient unconditionally makes http request on initialization #18

ryphill opened this issue Jan 13, 2020 · 1 comment

Comments

@ryphill
Copy link

ryphill commented Jan 13, 2020

Whenever you initialize an instance of AuthClient it calls get_discovery_doc which will issue a request to the intuit site.

This is inconvenient when running tests if the AuthClient is initialized at any point, even if it is not directly used:

  • Drastically slows down each test due to waiting on a response for the discovery document.
  • Adds an implicit dependency on one's internet connection as the affected tests will fail without one

If you want to avoid this performance penalty then you must mock the AuthClient in any test that might incidentally initialize an instance of it. In my case I was testing out an integration with quickbooks using the community python sdk and this caused my test suite to go from taking ~15s to about 1m17s.

This also means that if you have a view that redirects a user to the OAuth authorization url then your response timing will be dependent on the time for the discovery document to be retrieved.

Looking at the other intuit oauth client library, it looks like there is a split on retrieving the urls from the discovery document and storing the urls as constants in the library. The .NET and Java libraries both require you to make a request to the discovery document to get the OAuth urls whereas the PHP, Node, and Ruby libraries have them stored as constants.

From my perspective, it seems strictly better to store the urls as constants in the library as it removes any performance penalty that occurs from having to wait for a http response to retrieve the discovery doc when initializing the client.

@fjolin-intuit
Copy link
Collaborator

Hi @ryphill We are opening up issues for contribution for Hacktoberfest

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

No branches or pull requests

2 participants