Quickbooks身份验证错误-java sdk Quickbooks v3.0
这是我第一次尝试使用API。首先,我想尝试几个api调用 我已经在quickbooks上创建了帐户,并获得了以下凭据-Quickbooks身份验证错误-java sdk Quickbooks v3.0,java,web-services,rest,quickbooks,Java,Web Services,Rest,Quickbooks,这是我第一次尝试使用API。首先,我想尝试几个api调用 我已经在quickbooks上创建了帐户,并获得了以下凭据- consumerKey consumerSecret accessToken accessTokenSecret appToken companyId 从下载的包中,我目前正在使用以下jar文件- ipp-v3-java-devkit-2.3.2-jar-with-dependencies.jar ipp-java-qbapihelper-1.2.0-jar-with-dep
consumerKey
consumerSecret
accessToken
accessTokenSecret
appToken
companyId
从下载的包中,我目前正在使用以下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();
}
}
}
正在此处复制异常消息--
我正在检查quickbooks文档,但可以;无法找出导致此身份验证异常的原因。至于证书,我已经仔细检查过了,这些都是正确的
我发现quickbooks在这方面也有优势,但运气不好
已尝试此api调用-
https://appcenter.intuit.com/api/v1/PingSecure
我提供了我的凭证和指定的格式为JSON,没有url参数。
它正在返回以下消息-
{
"ErrorMessage": "This API requires Authorization.",
"ErrorCode": 22,
"ServerTime": "/Date(1412166272838)/"
}
我希望api不会返回身份验证错误,因为我的凭据是正确的。但是,我可以看到api调用的唯一方法是登录到
我真的不确定这里缺少什么-不能从api游乐场进行api调用,也不能以编程方式使用java sdk
任何帮助都将不胜感激。401建议出现“身份验证”错误 请参阅这篇文章,在这里我提到了如何使用任何标准的Restclient调用QBOV3端点 如果您再次看到401异常,请使用工具生成一组新的accessToken和accessSecret,并使用Javadevkit中的这些
谢谢请添加以下属性:
Config.setProperty(Config.BASE_URL_QBO,"https://sandboxquickbooks.api.intuit.com/v3/company");
之前:
DataService service = new DataService(context);
这对我有效。给定的URL无效。我把它改成了,它对我起了作用。
DataService service = new DataService(context);