PHPSample OAuth 连接 QBO 401
PHPSample OAuth connect QBO 401
我正在尝试在线连接到 Quickbooks。我已经尝试了几个包,包括 PHPSample、v3 SDK 中的示例代码和用于时间统计的 java 示例。我最终遇到了类似的问题。
我能够连接到 Quickbooks,并检索 realmId、oauth 令牌和 oauth 秘密。
在这种状态下,我可以成功断开连接。
当我随后连接并尝试查询数据(例如,所有帐户)时,我收到 401 错误。
这是 return 信息(删除了我的钥匙)
ERROR: Invalid auth/bad request (got a 401, expected HTTP/1.1 20X or a redirect)
Response: 401 - message=ApplicationAuthenticationFailed;
errorCode=003200;
statusCode=401
SignatureBaseString: POST
&https%3A%2F%2Fsandbox-quickbooks.api.intuit.com%2Fv3%2Fcompany%2F<REALM_ID>%2Fquery&minorversion%3D3%26oauth_consumer_key%3D<CONSUMER_KEY%26oauth_nonce%3D2172856b0bd6c51a491.36540409%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1454423404%26oauth_token%3D<OAUTH_TOKEN>%26oauth_version%3D1.0
array(6) {
["sbs"]=> string(369) "POST&https%3A%2F%2Fsandbox-quickbooks.api.intuit.com%2Fv3%2Fcompany%2F<REALM_ID>%2Fquery&minorversion%3D3%26oauth_consumer_key%3DI360v9TvxGoU7UoBYesJFUiRAkVQ8OQfV4Cbl2oN%26oauth_nonce%3D2172856b0bd6c51a491.36540409%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1454423404%26oauth_token%3DqyprdWBRfbyvECJdjDA98qR6G9oPvReu65EuFtFomxS5UPXP%26oauth_version%3D1.0"
["headers_sent"]=> string(532) "POST /v3/company/<REALM_ID>/query?minorversion=3 HTTP/1.1 host: sandbox-quickbooks.api.intuit.com user-agent: V3PHPSDK2.2.0 accept: */* connection: close content-type: application/text Authorization: OAuth oauth_consumer_key="<CONSUMER_KEY>",oauth_signature_method="HMAC-SHA1",oauth_nonce="2172856b0bd6c51a491.36540409",oauth_timestamp="1454423404",oauth_version="1.0",oauth_token="<OAUTH_TOKEN>",oauth_signature="<ALPHA_NUM_STRING>" Content-Length: 53"
["headers_recv"]=> string(147) "HTTP/1.1 401 Unauthorized Server: nginx/1.8.0 Date: Tue, 02 Feb 2016 14:29:35 GMT Content-Type: text/xml Content-Length: 797 Connection: close"
["body_sent"]=> string(53) "select * from Account startPosition 1 maxResults 1000"
["body_recv"]=> string(797) " message=ApplicationAuthenticationFailed; errorCode=003200; statusCode=401 SignatureBaseString: POST&https%3A%2F%2Fsandbox-quickbooks.api.intuit.com%2Fv3%2Fcompany%2F<REALM_ID>%2Fquery&minorversion%3D3%26oauth_consumer_key%3D<CONSUMER_KEY>%26oauth_nonce%3D2172856b0bd6c51a491.36540409%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1454423404%26oauth_token%3D<OAUTH_TOKEN>%26oauth_version%3D1.0 "
["info"]=> string(1280) "Adding handle: conn: 0x3a3c70 Adding handle: send: 0 Adding handle: recv: 0 Curl_addHandleToPipeline: length: 1 - Conn 5 (0x3a3c70) send_pipe: 1, recv_pipe: 0 About to connect() to sandbox-quickbooks.api.intuit.com port 443 (#5) Trying 12.149.173.155... Connected to sandbox-quickbooks.api.intuit.com (12.149.173.155) port 443 (#5) SSLv3, TLS handshake, Client hello (1): SSLv3, TLS handshake, Server hello (2): SSLv3, TLS handshake, CERT (11): SSLv3, TLS handshake, Server finished (14): SSLv3, TLS handshake, Client key exchange (16): SSLv3, TLS change cipher, Client hello (1): SSLv3, TLS handshake, Finished (20): SSLv3, TLS change cipher, Client hello (1): SSLv3, TLS handshake, Finished (20): SSL connection using AES256-SHA256 Server certificate: subject: C=US; ST=California; L=San Diego; O=INTUIT INC.; OU=Tech Ops; CN=*.api.intuit.com start date: 2015-11-23 00:00:00 GMT expire date: 2016-11-23 23:59:59 GMT issuer: C=US; O=Symantec Corporation; OU=Symantec Trust Network; CN=Symantec Class 3 Secure Server CA - G4 SSL certificate verify result: self signed certificate in certificate chain (19), continuing anyway. upload completely sent off: 53 out of 53 bytes Server nginx/1.8.0 is not blacklisted Closing connection 5 SSLv3, TLS alert, Client hello (1): " }
ERROR MESSAGE: message=ApplicationAuthenticationFailed; errorCode=003200; statusCode=401 SignatureBaseString: POST&https%3A%2F%2Fsandbox-quickbooks.api.intuit.com%2Fv3%2Fcompany%2F<REALM_ID>%2Fquery&minorversion%3D3%26oauth_consumer_key%3D<CONSUMER_KEY>%26oauth_nonce%3D2172856b0bd6c51a491.36540409%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1454423404%26oauth_token%3D<OAUTH_TOKEN>%26oauth_version%3D1.0
Note that
<CONSUMER_KEY> matches what is listed in the App page on intuit under OAuth Consumer Key
<OAUTH_TOKEN> matches what is returned from connect to quickbooks as the oauth token
<REALM_ID> matches what is returned from connect to quickbooks as the realm id
<ALPHA_NUM_STRING> is a string of alpha numeric characters (which look like a key string) that I do not recognize as coming from somewhere else.
我确定我做错了一些简单的事情,但我看不到它。
任何建议将不胜感激。
提前致谢。
请在此处查看您需要使用的沙箱密钥和基础 url-
请参考-
https://developer.intuit.com/v2/blog/2014/10/20/changes-to-ipp-app-tokens
https://developer.intuit.com/blog/2014/10/24/intuit-developer-now-offers-quickbooks-sandboxes
编辑:
因此,如果您使用过开发应用 keys/tokens 和沙盒 url,那么您的 oauth 应该可以正常工作。 401 is tokens expired/invalidated 错误,在以下情况下可能发生 - 当主管理员以外的用户尝试登录领域或使用错误的电子邮件 ID 登录时,会发生 401 错误。
如果主管理员在 QBO 公司中被删除,当一些其他用户或主管理员尝试使用相同的令牌再次使用连接到 Quickbooks 按钮时,它们也可能发生。
另一个原因是当管理员手动断开连接 realm/company 时会使令牌无效。
当我们这边出现中断时,也可能会出现 401。
最明显的原因是代币有 180 天的有效期。
除了我们这边的服务问题之外,还可以断开 tokens/invalidate 令牌并在你这边给出 401 错误。
重新生成令牌-
如果 180 天还没有结束并且令牌到期的剩余天数超过 30 days/180 天,则使用“连接到 Quickbooks”按钮通过电子邮件将其发送至“断开连接并重新连接”。
如果 180 天即将结束并且令牌到期的剩余天数在 30 天内,那么您的系统需要使用 Reconnect apis 来更新现有令牌。
https://developer.intuit.com/v2/docs/0050_quickbooks_api/0020_authentication_and_authorization/oauth_management_api
我正在尝试在线连接到 Quickbooks。我已经尝试了几个包,包括 PHPSample、v3 SDK 中的示例代码和用于时间统计的 java 示例。我最终遇到了类似的问题。
我能够连接到 Quickbooks,并检索 realmId、oauth 令牌和 oauth 秘密。
在这种状态下,我可以成功断开连接。
当我随后连接并尝试查询数据(例如,所有帐户)时,我收到 401 错误。
这是 return 信息(删除了我的钥匙)
ERROR: Invalid auth/bad request (got a 401, expected HTTP/1.1 20X or a redirect)
Response: 401 - message=ApplicationAuthenticationFailed;
errorCode=003200;
statusCode=401
SignatureBaseString: POST
&https%3A%2F%2Fsandbox-quickbooks.api.intuit.com%2Fv3%2Fcompany%2F<REALM_ID>%2Fquery&minorversion%3D3%26oauth_consumer_key%3D<CONSUMER_KEY%26oauth_nonce%3D2172856b0bd6c51a491.36540409%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1454423404%26oauth_token%3D<OAUTH_TOKEN>%26oauth_version%3D1.0
array(6) {
["sbs"]=> string(369) "POST&https%3A%2F%2Fsandbox-quickbooks.api.intuit.com%2Fv3%2Fcompany%2F<REALM_ID>%2Fquery&minorversion%3D3%26oauth_consumer_key%3DI360v9TvxGoU7UoBYesJFUiRAkVQ8OQfV4Cbl2oN%26oauth_nonce%3D2172856b0bd6c51a491.36540409%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1454423404%26oauth_token%3DqyprdWBRfbyvECJdjDA98qR6G9oPvReu65EuFtFomxS5UPXP%26oauth_version%3D1.0"
["headers_sent"]=> string(532) "POST /v3/company/<REALM_ID>/query?minorversion=3 HTTP/1.1 host: sandbox-quickbooks.api.intuit.com user-agent: V3PHPSDK2.2.0 accept: */* connection: close content-type: application/text Authorization: OAuth oauth_consumer_key="<CONSUMER_KEY>",oauth_signature_method="HMAC-SHA1",oauth_nonce="2172856b0bd6c51a491.36540409",oauth_timestamp="1454423404",oauth_version="1.0",oauth_token="<OAUTH_TOKEN>",oauth_signature="<ALPHA_NUM_STRING>" Content-Length: 53"
["headers_recv"]=> string(147) "HTTP/1.1 401 Unauthorized Server: nginx/1.8.0 Date: Tue, 02 Feb 2016 14:29:35 GMT Content-Type: text/xml Content-Length: 797 Connection: close"
["body_sent"]=> string(53) "select * from Account startPosition 1 maxResults 1000"
["body_recv"]=> string(797) " message=ApplicationAuthenticationFailed; errorCode=003200; statusCode=401 SignatureBaseString: POST&https%3A%2F%2Fsandbox-quickbooks.api.intuit.com%2Fv3%2Fcompany%2F<REALM_ID>%2Fquery&minorversion%3D3%26oauth_consumer_key%3D<CONSUMER_KEY>%26oauth_nonce%3D2172856b0bd6c51a491.36540409%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1454423404%26oauth_token%3D<OAUTH_TOKEN>%26oauth_version%3D1.0 "
["info"]=> string(1280) "Adding handle: conn: 0x3a3c70 Adding handle: send: 0 Adding handle: recv: 0 Curl_addHandleToPipeline: length: 1 - Conn 5 (0x3a3c70) send_pipe: 1, recv_pipe: 0 About to connect() to sandbox-quickbooks.api.intuit.com port 443 (#5) Trying 12.149.173.155... Connected to sandbox-quickbooks.api.intuit.com (12.149.173.155) port 443 (#5) SSLv3, TLS handshake, Client hello (1): SSLv3, TLS handshake, Server hello (2): SSLv3, TLS handshake, CERT (11): SSLv3, TLS handshake, Server finished (14): SSLv3, TLS handshake, Client key exchange (16): SSLv3, TLS change cipher, Client hello (1): SSLv3, TLS handshake, Finished (20): SSLv3, TLS change cipher, Client hello (1): SSLv3, TLS handshake, Finished (20): SSL connection using AES256-SHA256 Server certificate: subject: C=US; ST=California; L=San Diego; O=INTUIT INC.; OU=Tech Ops; CN=*.api.intuit.com start date: 2015-11-23 00:00:00 GMT expire date: 2016-11-23 23:59:59 GMT issuer: C=US; O=Symantec Corporation; OU=Symantec Trust Network; CN=Symantec Class 3 Secure Server CA - G4 SSL certificate verify result: self signed certificate in certificate chain (19), continuing anyway. upload completely sent off: 53 out of 53 bytes Server nginx/1.8.0 is not blacklisted Closing connection 5 SSLv3, TLS alert, Client hello (1): " }
ERROR MESSAGE: message=ApplicationAuthenticationFailed; errorCode=003200; statusCode=401 SignatureBaseString: POST&https%3A%2F%2Fsandbox-quickbooks.api.intuit.com%2Fv3%2Fcompany%2F<REALM_ID>%2Fquery&minorversion%3D3%26oauth_consumer_key%3D<CONSUMER_KEY>%26oauth_nonce%3D2172856b0bd6c51a491.36540409%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1454423404%26oauth_token%3D<OAUTH_TOKEN>%26oauth_version%3D1.0
Note that
<CONSUMER_KEY> matches what is listed in the App page on intuit under OAuth Consumer Key
<OAUTH_TOKEN> matches what is returned from connect to quickbooks as the oauth token
<REALM_ID> matches what is returned from connect to quickbooks as the realm id
<ALPHA_NUM_STRING> is a string of alpha numeric characters (which look like a key string) that I do not recognize as coming from somewhere else.
我确定我做错了一些简单的事情,但我看不到它。 任何建议将不胜感激。
提前致谢。
请在此处查看您需要使用的沙箱密钥和基础 url- 请参考- https://developer.intuit.com/v2/blog/2014/10/20/changes-to-ipp-app-tokens https://developer.intuit.com/blog/2014/10/24/intuit-developer-now-offers-quickbooks-sandboxes 编辑: 因此,如果您使用过开发应用 keys/tokens 和沙盒 url,那么您的 oauth 应该可以正常工作。 401 is tokens expired/invalidated 错误,在以下情况下可能发生 - 当主管理员以外的用户尝试登录领域或使用错误的电子邮件 ID 登录时,会发生 401 错误。 如果主管理员在 QBO 公司中被删除,当一些其他用户或主管理员尝试使用相同的令牌再次使用连接到 Quickbooks 按钮时,它们也可能发生。 另一个原因是当管理员手动断开连接 realm/company 时会使令牌无效。 当我们这边出现中断时,也可能会出现 401。
最明显的原因是代币有 180 天的有效期。 除了我们这边的服务问题之外,还可以断开 tokens/invalidate 令牌并在你这边给出 401 错误。
重新生成令牌- 如果 180 天还没有结束并且令牌到期的剩余天数超过 30 days/180 天,则使用“连接到 Quickbooks”按钮通过电子邮件将其发送至“断开连接并重新连接”。 如果 180 天即将结束并且令牌到期的剩余天数在 30 天内,那么您的系统需要使用 Reconnect apis 来更新现有令牌。 https://developer.intuit.com/v2/docs/0050_quickbooks_api/0020_authentication_and_authorization/oauth_management_api