我正在使用 QB 桌面版。并且我想为我的 QuickBooks 桌面版续订/重新生成“访问令牌”/“访问令牌秘密”,因为它们将在 180 天内到期,并且必须在令牌到期后的 30 天内进行续订。我用下面的代码尝试了同样的方法,但它不起作用,给出错误,
<RestResponse xmlns="http://www.intuit.com/sb/cdm/v2"><Error RequestId="14aa97c48321489db48254e4bdb25d00"><RequestName>ErrorRequest</RequestName><ProcessedTime>2013-04-05T11:43:08+00:00</ProcessedTime><ErrorCode>401</ErrorCode><ErrorDesc>Invalid security token</ErrorDesc></Error></RestResponse>
令牌生成没有任何记录的请求/响应。
string myRealmId = "000000000000000";
string myAccessToken = "0000000000000000000000000000000000000";
string myAccessTokenSecret = "00000000000000000000000000000000000";
string myAppToken = "00000000000000000000000000000000000";
string myConsumerKey ="00000000000000000000000000000000000";
string myConsumerSecret ="00000000000000000000000000000000000";
OAuthConsumerContext consumerContext = new OAuthConsumerContext
{
ConsumerKey =myConsumerKey,
SignatureMethod = SignatureMethod.HmacSha1,
ConsumerSecret = myConsumerSecret
};
OAuthSession oSession = new OAuthSession(consumerContext, "https://oauth.intuit.com/oauth/v1/get_request_token",
"https://workplace.intuit.com/Connect/Begin",
"https://oauth.intuit.com/oauth/v1/get_access_token");
oSession.ConsumerContext.UseHeaderForOAuthParameters = true;
oSession.AccessToken = new TokenBase
{
Realm = myRealmId,
Token = myAccessToken,
ConsumerKey = myConsumerKey,
TokenSecret = myAccessTokenSecret
};
var body = "<AdvancedReportQuery xmlns=\"http://www.intuit.com/sb/cdm/v2\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.intuit.com/sb/cdm/v2 ..//RestDataFilter.xsd\"><BalanceSheetStd><OfferingId>ipp</OfferingId><EndTransactionDate>2012-06-01</EndTransactionDate></BalanceSheetStd></AdvancedReportQuery>";
IConsumerRequest conReq = oSession.Request();
conReq = conReq.Post().WithRawContentType("text/xml").WithRawContent(System.Text.Encoding.ASCII.GetBytes(body));
conReq = conReq.ForUrl("https://services.intuit.com/sb/advancedreport/v2/508053445");
try
{
conReq = conReq.SignWithToken();
}
catch (Exception ex) {}
string serviceResponse = conReq.ReadBody();
}
catch (Exception Err) {}
}
谢谢,
瑞诗玛 D.