这是我第一次尝试使用Quickbooks API。要开始使用它,我想尝试一些API调用。Quickbooks身份验证错误 - java sdk quickbooks v3.0
我已经创建的帐户上的QuickBooks,并获得以下凭据 -
consumerKey
consumerSecret
accessToken
accessTokenSecret
appToken
companyId
下载IPP java sdk for QuickBooks v3.0和从下载包,我目前使用下面的jar文件 -
ipp-v3-java-devkit-2.3.2-jar-with-dependencies.jar
ipp-java-qbapihelper-1.2.0-jar-with-dependencies.jar
这里是我正在执行的代码。
import com.intuit.ipp.core.Context;
import com.intuit.ipp.core.ServiceType;
import com.intuit.ipp.data.Customer;
import com.intuit.ipp.exception.FMSException;
import com.intuit.ipp.security.OAuthAuthorizer;
import com.intuit.ipp.services.DataService;
public class TestQuickBooks {
public static void main(String[] args)
throws FMSException
{
// following credentials are replaced with my original credential
// when executing the code
String consumerKey = "...";
String consumerSecret = "...";
String accessToken = "...";
String accessTokenSecret = "...";
String appToken = "...";
String companyId = "...";
try {
OAuthAuthorizer oauth = new OAuthAuthorizer(consumerKey,
consumerSecret,
accessToken,
accessTokenSecret);
Context context = new Context(oauth,
appToken,
ServiceType.QBO,
companyId);
DataService service = new DataService(context);
Customer customer1 = new Customer();
customer1.setDisplayName("ABCD");
// this is the line which is throwing exception
Customer resultCustomer = service.add(customer1);
} catch (Exception e) {
e.printStackTrace();
}
}
}
复制异常消息在这里 -
com.intuit.ipp.exception.AuthenticationException: ERROR CODE:3200, ERROR MESSAGE:message=ApplicationAuthenticationFailed; errorCode=003200; statusCode=401, ERROR DETAIL:null
我检查QuickBooks的文档,但可以;吨弄清楚是什么原因造成这种身份验证例外。至于证书,我已经仔细检查过,这些都是正确的。
我发现快速书有一个API playground,但也没有运气。
试过这个API调用 -
https://appcenter.intuit.com/api/v1/PingSecure
我提供我的凭据,并指定格式,JSON和无URL参数。 它返回下面的消息 -
{
"ErrorMessage": "This API requires Authorization.",
"ErrorCode": 22,
"ServerTime": "/Date(1412166272838)/"
}
我希望是API的操场不应该返回验证错误,因为我的凭据是正确的。不过,我可以看到API调用的唯一办法是,当我登录到API explorer
我真的不知道这是怎么丢失 - 不能让从API游乐场,以及以编程方式使用Java SDK的API调用。
任何帮助,将不胜感激。