How to create a Quickbooks Online request signature in PHP

本秂侑毒 提交于 2020-01-05 09:04:29

问题


I know QBO doesn't natively support PHP, but If I can get authenticated requests working, I can just use their API directly.

I've got the following pieces of data

appid
oAuth consumer key
oAuth secret key

I'm making an API call to this endpoint

https://qb.sbfinance.intuit.com/v3/company/<<my company id>>/item

I'm using googles oauth-php library to try to make this work. Here is the result

message=Exception authenticating OAuth; errorCode=003200; statusCode=401

I'm obviously missing details on what to do here, ex: how to send the app id along with this. Does anyone have any experience or examples of getting a signature using PHP?

Thanks!


回答1:


We have a complete QuickBooks PHP library that has a working OAuth implementation.

You can download it here:

  • QuickBooks PHP DevKit

There's an authentication example at:

  • docs/example_ipp_oauth.php

And data access examples at:

  • docs/example_ipp_ids_5.php
  • docs/example_ipp_ids_6.php
  • docs/example_ipp_ids_7.php

The Google OAuth libs should work also- it's a standard OAuth implementation and we've used the Google OAuth libs successfully in the past.




回答2:


Error 401 suggests some authentication issues. So, please verify your tokens using ApiExplorer tool(or any other RestClient) and verify the request header.

Using V2 ApiExplorer, you can get the API endpoint.

  • V2 - https://developer.intuit.com/apiexplorer?apiname=V2QBO

Apiexplorer donsn't show the OAuth tokens. So, I would suggest you to use the following link to generate OAuth tokens. You can call the endpoint which you got from the Apiexplorer using the newly generated OAuth tokens. If it works, then use those tokens in you PHP application.

[PN - OAuth tokens don't depend upon API version ]

  • https://appcenter.intuit.com/playground/oauth [ It works with V2 ]

Thanks




回答3:


Since, this question is for v3 API access, you need to access- developer.intuit.com/apiexplorer?apiname=V3QBO

Refer to the ouath 1.0 docs to generate the signature as mentioned below: http://oauth.net/core/1.0a/ http://oauth.net/core/1.0/#signing_process

Twitter example for generating signature- https://dev.twitter.com/docs/auth/creating-signature

Sample RAW REQUEST AND RESPONSE headers-

Request:

Authorization: OAuth oauth_token="CCCDOPwLGymIrFSHVZ317Qx",oauth_nonce="cddde-464b-458a-a718-2dcd8062616a",oauth_consumer_key="qyprtysdsdgJZUvWDFnPoiBh1ejZn",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1379398521",oauth_version="1.0",oauth_signature="mwVUkoHnh%2BPLqZolso2rzX5aABM%3D"

Response Header:

Cache-Control : max-age=0, no-cache, no-store, must-revalidate, private Connection : close Content-Length : 1402 Content-Type : application/xml;charset=UTF-8 Date : Tue, 17 Sep 2013 06:27:48 GMT Expires : 0 intuit_tid : 0f9b5431-b713-4d55-ac24-c00f4e91848e Server : Apache/2.2.22 (Unix) Vary : Accept-Encoding Via : 1.1 ipp-gateway-.net



来源:https://stackoverflow.com/questions/18838132/how-to-create-a-quickbooks-online-request-signature-in-php

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