Quickbooks online API with oauth2

不想你离开。 提交于 2020-01-02 09:31:32

问题


I need to use Quickbooks online API to synchronize data between my system and my client's accounts on quickbooks.

I need to know if is it possible to complete the oauth2 authorization flow and make API calls without human interaction (without the need to interact with Intuit's authentication and authorization windows)?

I read the Intuit's docs on: https://developer.intuit.com/docs/0100_quickbooks_online/0100_essentials/000500_authentication_and_authorization/connect_from_within_your_app

On the first step, I made a GET request to:

https://appcenter.intuit.com/connect/oauth2?client_id=MY_ID&scope=com.intuit.quickbooks.accounting&redirect_uri=https%3A%2F%2FMY_NGROK_URL.ngrok.io%2FOAuth2PHPExample.php&response_type=code&state=RandomState#/Authorize/COMPANY_ID

Then, the Intuit's authentication and authorization windows opens and I need to put my username and password and then, click in the authorize button to get the authorization code.

Is there a way to obtain the authorization code without authenticate and authorize?

I need to automate this task to make API calls in the backend with PHP.

Thanks, Marcelo.


回答1:


Is there a way to obtain the authorization code without authenticate and authorize?

No... but read below.

I need to automate this task to make API calls in the backend with PHP.

You are misunderstanding how OAuth (either 1 or 2) works.

The very first time you connect you will be prompted to authenticate/authorize access to the QuickBooks Online data.

You are then given a refresh token (or access token depending on if you're using OAuth2 vs. OAuth1).

You then store that refresh token (or access token for OAuth1) and can use that token going forward to make your requests, unattended, without requiring the user to be involved at all.

Key take-away: You only need the user involved the VERY FIRST TIME you connect, and then never again.



来源:https://stackoverflow.com/questions/45509192/quickbooks-online-api-with-oauth2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!