在 .net SDK MYOB 中进行调用时是否需要 ICompanyFileCredentials

Is ICompanyFileCredentials required when making calls in .net SDK MYOB

我正在尝试将 MYOB .net SDK 集成到我的 Web 应用程序 (C#) 中。我对 ICompanyFileCredentials 有一些疑问。它是公司文件的登录凭据。像这段代码调用服务时是否必须提交?

var service = new ItemOrderService(SessionManager.MyConfiguration, null, SessionManager.MyOAuthKeyService);
var list = service.GetRange(SessionManager.SelectedCompanyFile, filter + pageFilter, SessionManager.MyCredentials, null);

为了确定,我检查了很多服务的重载方法。我看不到允许凭据可选的重载方法。所以我认为这是强制性的。但话又说回来 link:

https://apisupport.myob.com/hc/en-us/articles/360000576836-Company-file-authentication

我引用了:

If you get an HTTP 403 "Access Denied" response, you don't yet have permissions to login to that file. This is because some users have not linked their my.myob login with their per-file company file login. You could prompt them to link their login (it's Step 5 of our help guide "Opening a company file"), or you could allow your client to provide their per-file user credentials to your application.

这让我有点困惑,因为用户是否link编辑了他们的my.myob登录并不重要,打电话时需要凭据(至少这是真的在 .net SDK 中),因为它是必需的参数。

有人可以确认打电话时是否需要凭据吗?如果是,用户如何找出他们公司的文件凭据是什么?他们不需要在桌面上输入这些凭据很多次?谢谢

访问MYOB SDK需要提供两套凭证

以下是我自己在 MYOB 项目上的一些示例代码:

1) 访问 MYOB 以获取您有权访问的公司列表,这需要一个 Developer Key & Secret 和一个 oAuth key(这是您的在线帐户)。

ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
            Configuration = new ApiConfiguration(MYOBModule.DeveloperKey, MYOBModule.DeveloperSecret, MYOBModule.MYOBConfirmationUrl);
            var cfService = new CompanyFileService(Configuration, null, Keys);

获得公司列表后,您需要通过文件用户名/密码访问您的个人公司

        Credentials = new CompanyFileCredentials(MYOBModule.CompanyFileUsername, MYOBModule.CompanyFilePassword);

所以是的,您需要两套身份验证。