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.
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 --
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-libraryQuickBooks 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-requestaccess 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:
access token - https://developer.intuit.com/app/developer/qbo/docs/develop/authentication-and-authorization/oauth-2.0#refresh-the-tokenaccess 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) 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With