0

我想连接到 Xero API,我有以下代码:

using Xero.Api;
using Xero.Api.Core;
using Xero.Api.Example.Applications.Public;
using Xero.Api.Infrastructure.OAuth;
using Xero.Api.Infrastructure.Interfaces;
using Xero.Api.Serialization;

var public_app_api = new XeroCoreApi("https://api.xero.com", new PublicAuthenticator("https://api.xero.com", "https://api.xero.com", "oob",
                new MemoryTokenStore()),
                new Consumer("KOWORD7XK14UL1HOKJO2YQIHMHB8NV", "CDMNUVXXF8PN8UFZGJJXCWR1P8SAL6"),user,
                new DefaultMapper(), new DefaultMapper());
var public_contacts = public_app_api.Contacts.Find().ToList();

我的问题是我收到了这个错误:

oauth_problem=permission_denied & oauth_problem_advice=The consumer was denied access to this resource

我将被引导到授权应用程序,他们提供了要输入的代码,但我不知道在哪里可以输入这些代码。有人可以帮我吗?谢谢。

4

1 回答 1

0

返回的代码是一个 oauth 验证器(“oauth_verifier”),它应该在您的调用中提供以获取访问令牌。

Its basically appending your Authorize URL with your 'oauth_verifier' something like this : https://api.xero.com/oauth/AccessToken?oauth_consumer_key=WLVBLGE7EIDADYYUDMUUI8N4JYXNZ6&oauth_token=QDND3QPOOJAYC0CRPRDVSR8QBIPPXL&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1494813490&oauth_nonce=1cdSIE&oauth_version=1.0&oauth_signature=zL5XYfAi1+3GUtvx/ J5prvbhCVI=&oauth_verifier=2654410

于 2017-05-22T21:08:41.250 回答