Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i authenticate my Quickbook Intuit api access without user interection and just by client id and secret?

I am working on a project where backgroung crons create invoices and i want to add them on my quickbook account on create on backend, so problem is i want to hit api with just client id and secret involvement.

like image 406
Mohsin Malik Avatar asked Nov 23 '25 02:11

Mohsin Malik


1 Answers

How can i authenticate my Quickbook Intuit api access without user interection and just by client id and secret?

You can't. But you don't need to either. You misunderstand how OAuth v2 works when using refresh token type grants.

The way OAuth v2 with refresh token grants works is like this --

  • The developer goes through a one-time UI process to get the client ID and client secret, and define callback URLs - https://developer.intuit.com/app/developer/qbo/docs/develop/authentication-and-authorization/oauth-2.0#download-the-oauth-library
  • The person who owns the QuickBooks Online account goes through a one-time and only one-time UI-based connection process which exchanges the client ID and client secret for an authorization code, and then that for an access token and refresh token - https://developer.intuit.com/app/developer/qbo/docs/develop/authentication-and-authorization/oauth-2.0#step-1-prepare-authorization-request
  • Your code stores the OAuth access and refresh tokens.

Now, you can run your cron job whenever you want, using the stored access and refresh tokens.

At some point, you will get back a 401 response from Intuit - this means your access token has expired (it is only valid for 1 hour). When this happens:

  • Make an API call to refresh the access token - https://developer.intuit.com/app/developer/qbo/docs/develop/authentication-and-authorization/oauth-2.0#refresh-the-token
  • Store the new access token and the new refresh token (you may or may not get back a new refresh token, so you should just store what you get back every time regardless)
  • Make your API call again, and it will succeed

Repeat in your cron process whenever you want, as desired.

To re-iterate - the UI-based auth process is one-time and one-time ONLY. After that one-time process you store the tokens and can make calls from your background/cron processes whenever you need to.

like image 93
Keith Palmer Jr. Avatar answered Nov 24 '25 16:11

Keith Palmer Jr.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!