简体   繁体   English

如何进行身份验证以访问我们自己的数据?

[英]How to authenticate to access our own data?

I'm trying to use IDS to access our own data in QBO from a java-based web app. 我正在尝试使用IDS从基于Java的Web应用程序访问我们在QBO中的数据。 I've found some examples (such as the example in ipp-java-devkit) and have assembled about 20 lines of code just to connect and authenticate...and I don't have anything working yet. 我找到了一些示例(例如ipp-java-devkit中的示例),并组装了约20行代码来进行连接和身份验证……而我还没有任何工作。 The docs seem to be oriented around building a 3rd-party app to sell to other companies so that they can access their own data from the app. 这些文档似乎围绕构建第三方应用程序出售给其他公司,以便他们可以从该应用程序访问自己的数据。 I understand the need for extra security in that case, but surely I should not need to create an application in the Intuit App Store simply to access our own data? 我知道在这种情况下需要额外的安全性,但是我肯定不需要仅在Intuit App Store中创建应用程序来访问我们自己的数据吗?

Does anyone know of an example or tutorial on how to do this? 有人知道如何执行此操作的示例或教程吗?

Per Intuit's FAQ , Intuit Anywhere/IDS is only supposed to be used for SaaS applications (eg an app you're trying to sell to other people, which allows them to connect their QuickBooks files to your app). 根据Intuit的常见问题解答 ,Intuit Anywhere / IDS仅应用于SaaS应用程序(例如,您正试图出售给其他人的应用程序,从而允许他们将QuickBooks文件连接到您的应用程序)。

From the FAQs: 从常见问题解答:

Q: What are the requirements for implementing Intuit Anywhere? 问:实施Intuit Anywhere的要求是什么?

A: Your app must: 答:您的应用必须:

  • Be a web app available for use within a browser, that is sold as service (SaaS, including transactional pricing based) offering that you sell to multiple customers. 成为可在浏览器中使用的Web应用程序,即作为服务销售(SaaS,包括基于交易定价)的产品,并销售给多个客户。 Mobile extensions to your SaaS app are supported. 支持SaaS应用程序的移动扩展。

  • Pass the Security Review prior to going live with customers. 在与客户交流之前,请通过安全性审查。

And: 和:

Q: I want to integrate my custom (non-SaaS, single-tenant) solution with Intuit Anywhere. 问:我想将我的自定义(非SaaS,单租户)解决方案与Intuit Anywhere集成。 > Can I do this? >我可以这样做吗?

A: Not today, but we are considering it. 答:不是今天,但是我们正在考虑。

Since what you're trying to build doesn't fall into that pattern, you are not eligible to use IDS. 由于您尝试构建的内容不属于该模式,因此您没有资格使用IDS。

You should use qbXML instead. 您应该改用qbXML。

On our QuickBooks integration wiki we have some examples of connecting to QuickBooks Online in Java. 在我们的QuickBooks集成Wiki上,我们有一些使用Java连接到QuickBooks Online的示例。

You should register in DESKTOP mode with Intuit, and then you can use code like this to exchange data: 您应该使用Intuit 在DESKTOP模式下注册 ,然后可以使用如下代码交换数据:

import java.net.*;
import java.io.*;
import javax.net.ssl.*;

// WARNING SUPER SLOPPY DEMO CODE - YOU SHOULD CLEAN THIS UP AND MAKE THIS PRETTY IF YOU USE IT!

public class Test {

    protected static String _appID = "134476472";

    protected static String _appLogin = "test.www.yourdomain.com";

    protected static String _connTicket = "TGT-47-1sRm2nXMVfm$n8hb2MZfVQ";

    protected static String _appURL = "https://webapps.quickbooks.com/j/AppGateway";

    /**
     * @param args
     */
    public static void main(String[] args) {

        // First, we need to sign on to QBOE
        String xml = "<?xml version=\"1.0\" ?>" + 
        "<?qbxml version=\"6.0\"?>" + 
        "<QBXML>" + 
        "   <SignonMsgsRq>" + 
        "       <SignonDesktopRq>" + 
        "           <ClientDateTime>2007-01-02T01:02:35</ClientDateTime>" + 
        "           <ApplicationLogin>" + Test._appLogin + "</ApplicationLogin>" + 
        "           <ConnectionTicket>" + Test._connTicket + "</ConnectionTicket>" + 
        "           <Language>English</Language>" + 
        "           <AppID>" + Test._appID + "</AppID>" + 
        "           <AppVer>1</AppVer>" + 
        "       </SignonDesktopRq>" + 
        "   </SignonMsgsRq>" + 
        "</QBXML>";

        String out = "";
        try {
            out = Test._doRequest(xml);
            System.out.println(out);
        }
        catch (Exception ex) {
            System.out.println("Something bad happened: " + ex.getMessage());
        }

        // Parse out the connection ticket
        String sessTicket = out.substring(291, 330);
        System.out.println("Session ticket: " + sessTicket);

        // Send an actual request
        String xml2 = "<?xml version=\"1.0\" ?>" +  
"<?qbxml version=\"6.0\"?>" +  
"<QBXML> " + 
"   <SignonMsgsRq>" + 
"       <SignonTicketRq>" +  
"           <ClientDateTime>2006-09-20T15:49:26</ClientDateTime>" +  
"           <SessionTicket>" + sessTicket + "</SessionTicket>" + 
"           <Language>English</Language> " + 
"           <AppID>" + Test._appID + "</AppID>" + 
"           <AppVer>1</AppVer>" +  
"       </SignonTicketRq>" +  
"   </SignonMsgsRq>" +  
"   <QBXMLMsgsRq onError=\"continueOnError\">" +  
"       <CustomerQueryRq requestID=\"2\" />" +  
"   </QBXMLMsgsRq>" +  
"</QBXML>";

        try {
            System.out.println(Test._doRequest(xml2));      
        }
        catch (Exception ex) {
            System.out.println("Something bad happened: " + ex.getMessage());
        }
    }

    protected static String _doRequest(String xml) throws Exception {
        String xmlOut = null;

               try 
               {
                  URL url= new URL(Test._appURL);
                  HttpsURLConnection connection = (HttpsURLConnection)url.openConnection();
                  connection.setDoOutput(true);
                  connection.setDoInput(true);

                  connection.setRequestProperty("Content-Type", "application/x-qbxml");

                  PrintWriter out = new PrintWriter(connection.getOutputStream());
                  out.println(xml); //XML Input
                  out.close();
                  BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
                  String inputLine = "";
                  xmlOut = "";
                  StringBuffer strOut = new StringBuffer();

                  while ((inputLine = in.readLine()) != null)
                  {
                      strOut.append(inputLine);
                  }
                  xmlOut = strOut.toString();

                  in.close();
               }
               catch(ConnectException conEx)
               {
                  System.out.println("Connection is unavailable. (ConnectException in SecureEnterpriseSocketSession class) " + conEx);
                  throw new Exception(conEx.getMessage());
               }
               catch(MalformedURLException malformedURLEx)
               {
                  System.out.println("Invalid URL. Cannot Connect. (MalformedURLException in SecureEnterpriseSocketSession class) " + malformedURLEx);
                  throw new Exception(malformedURLEx.getMessage());
               }
               catch(IOException ioEx)
               {
                  System.out.println("Invalid URL. Cannot Connect. (IOException in SecureEnterpriseSocketSession class) " + ioEx);
                  throw new Exception(ioEx.getMessage());
               }
               return xmlOut;
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM