简体   繁体   English

通过Intuit API访问quickBooks数据时,.NET中出现“ Unauthorized-401”错误

[英]Getting “Unauthorized-401” Error in .NET while accessing quickBooks data through Intuit API

I am developing a .NET(C#) application with QuickBooks integration using Intuit API. 我正在使用Intuit API开发具有QuickBooks集成的.NET(C#)应用程序。 I've created 2 Intuit Accounts, say A and B, with different QuickBooks data. 我用不同的QuickBooks数据创建了2个Intuit帐户(分别为A和B)。

I connect and authorize Intuit account A and create a Client, C1, with same in my application. 我连接并授权Intuit帐户A,并在我的应用程序中创建一个客户C1。 Then I connect and authorize B and create another Client, C2, in my application. 然后,我连接并授权B并在我的应用程序中创建另一个客户端C2。 Till this point everything works fine. 至此,一切正常。 I save the oAuth information like access token, access token secret, key etc. in database when I create the Clients. 创建客户端时,我将oAuth信息(例如访问令牌,访问令牌密钥,密钥等)保存在数据库中。 And fetch the respective information when I want to edit a particular Client. 并在我要编辑特定客户端时获取相应的信息。

(Remember my application was last authorized Intuit Account B when C2 was created) (记住创建C2时我的应用程序是上次授权的Intuit帐户B)

Now, at this moment, if I go to Client C1 which is connected with Intuit Account A, and try to fetch quickbooks data, without going through default connect and authorize process of intuit using “connect to intuit” button, it gives me “Unauthorized-401” Error, even though I am providing oAuth information like access token, secret, key etc. which was saved in local database during Client creation. 现在,此刻,如果我转到与Intuit帐户A连接的客户端C1,并尝试获取快速簿数据,而没有使用“ connect to intuit”按钮进行默认的intuit连接和授权过程,它将显示“未经授权” -401”错误,即使我提供的oAuth信息(如访问令牌,秘密,密钥等)也已在创建客户端时保存在本地数据库中。 QuickBooks throws error as soon as I fire API method to fetch data. 我启动API方法来获取数据后,QuickBooks就会引发错误。

I don't want my application to manually connect and authorize Intuit account process every time it tries to fetch data from a different Intuit account, As there is an automated background job which sync every Client's QuickBooks data after every 24 hrs. 我不希望我的应用程序每次尝试从另一个Intuit帐户获取数据时都手动连接并授权Intuit帐户流程,因为有一个自动后台作业,该作业每24小时就会同步每个客户的QuickBooks数据。 It is not possible to manually authorize the same with that job. 不能手动授权该作业。

What I am missing here? 我在这里想念的是什么? What should I do? 我该怎么办? Do I need to purchase any Partner License or something ? 我需要购买任何合作伙伴许可证或其他东西吗?

For a given apptoken, consumerKey and consumerSecret only one user of a particular QBO account will have valid OAuth credential. 对于给定的apptoken,consumererKey和consumerSecret,只有特定QBO帐户的一个用户才能拥有有效的OAuth凭据。 If a second user of that particular company goes through C2QB cycle(OAuth handshake) to generate new accessToken and accessSecret then the previous tokens get invalidated. 如果该特定公司的第二个用户经历了C2QB周期(OAuth握手)以生成新的accessToken和accessSecret,则先前的令牌将失效。

There is no need for going through OAuth cycle each time when end user access your app. 最终用户每次访问您的应用时,都无需经历OAuth周期。 You can associate the end user's SSO id with valid OAuth tokens in DB for the very first time when he generates OAuth tokens(using C2QB button ). 您可以在最终用户生成OAuth令牌时(使用C2QB button)第一次将最终用户的SSO ID与DB中的有效OAuth令牌相关联。 From next time onwords just have him go through intuit's SSO flow, fetch OAuth credentials based on his SSO identifier and allow him to access his data using his that previously saved credential. 从下一次开始,onword便使他经历了intuit的SSO流程,根据他的SSO标识符获取OAuth凭据,并允许他使用先前保存的凭据访问其数据。

Thanks 谢谢

For a master admin of a company file, tokens cannot be invalidated unless Connect to Quickbooks(C2QB) is used for the same realm by your app. 对于公司文件的主管理员,除非您的应用将Connect to Quickbooks(C2QB)用于同一领域,否则令牌不能无效。 Only this can render the tokens invalid. 只有这样才能使令牌无效。 Please check if you are saving the tokens in some temp store and not deleting/cleaning it which can cause expiring of tokens. 请检查是否将令牌保存在某些临时存储区中,而不要删除/清除它可能导致令牌过期的临时存储。 Since, the two QBO accounts/realms A and B and the admins(C1 and C2) are not related, there is no reason that generating the oauth tokens for B could cause tokens to expire for A. 由于两个QBO帐户/领域A和B与admins(C1和C2)不相关,因此没有理由为B生成oauth令牌可能导致A的令牌过期。

暂无
暂无

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

相关问题 从我的C#应用​​程序访问webDav文件夹时出现401未经授权的错误? - Getting 401 unauthorized error while accessing webDav folder from my C# application? 在将Hammock与Tumblr API结合使用以检索喜欢项时,为什么会出现此401未经授权的错误? - Why am I getting this 401 unauthorized error while using Hammock with the Tumblr API to retrieve likes? 无法调试 401 Unauthorized error in.Net 6 Web API - Unable to debug 401 Unauthorized error in .Net 6 Web API 为什么我在 Google Calendar API 中收到 (401) 未经授权的错误 - Why am I getting a (401) Unauthorized Error in Google Calendar API 对.NET Web Api服务的Web请求获取401未经授权的错误 - Web request to .NET Web Api Service gets 401 unauthorized error 将 API 迁移到 .net Core 3 时出现 JWT 401 未授权错误 - JWT 401 unauthorized error on migrating API to .net Core 3 获取 StatusCode:401,ReasonPhrase:'Unauthorized',版本:1.1,内容:System.Net.Http.StreamContent,通过代码调用 API 时出现标题错误 - Getting StatusCode: 401, ReasonPhrase: 'Unauthorized', Version: 1.1, Content: System.Net.Http.StreamContent, Headers error when Calling a API via code Intuit Quickbooks在线API-如何购买 - Intuit Quickbooks Online API - How to get purchases 获得未经授权的 401 ASP.NET 核心 6 - Getting 401 unauthorized ASP.NET CORE 6 应用程序更新程序-不断收到401未经授权的错误 - Application Updater - Keep getting 401 Unauthorized error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM