我正在尝试在线连接到QB,我遇到了问题。我为QBO创建了一个模拟账户,并将我的测试应用添加到了账户并授予了我的应用访问权限。我有我的消费者密钥和秘密令牌。我已经安装了.net devkit并安装了我的测试项目。
我正在使用此处的代码示例...
一切正常,直到我调用add方法来创建客户。就添加数据而言,我尝试做的任何其他事情都是如此。
这是我得到的错误......
“message =异常验证OAuth; errorCode = 003200; statusCode = 401; source = OAuthStrategy; oauth_problem = token_rejected; cause = net.oauth.OAuthProblemException:token_rejected”
它说令牌被拒绝所以我不清楚我错过了什么。这些是在线应用程序部分提供给我的令牌。
这是我的代码..
Dim AccessToken As String = [redacted]
Dim AccessTokenSecret As String = [redacted]
Dim ConsumerKey As String = [redacted]
Dim ConsumerSecret As String = [redacted]
Dim OAuthValidator As OAuthRequestValidator = New OAuthRequestValidator(AccessToken, AccessTokenSecret, ConsumerKey, ConsumerSecret)
Dim Context As ServiceContext = New ServiceContext(OAuthValidator, RealmID, IntuitServicesType.QBD)
Dim dataServices As DataServices = New DataServices(Context)
Dim qbdCustomer As Customer = New Customer()
With qbdCustomer
qbdCustomer.Name = "My New Customer"
qbdCustomer.GivenName = "New Customer"
qbdCustomer.FamilyName = "New Customer"
End With
Dim customerAdded As Customer = dataServices.Add(qbdCustomer)
答案 0 :(得分:3)
如果您尝试连接到QBO,则使用的是错误的实体。
你应该使用QBO而不是QBD。
此外,您的InitializeServiceContext看起来缺少一些参数。