【发布时间】:2019-09-26 05:49:25
【问题描述】:
我正在尝试在需要首先获取持有者令牌的控制台应用程序中调用 Quick Books Online API。下面是代码 sn-p,我在其中尝试首先获取授权代码以进行后续访问令牌调用。我收到的是 HTML 响应,而不是带有验证码的 json 对象。
另外,QBO 支持哪些资助类型?
HttpClientHandler httpClientHandler = new HttpClientHandler();
HttpClient httpClient = new HttpClient(httpClientHandler,false);
httpClient.BaseAddress = new Uri("https://appcenter.intuit.com/connect/oauth2");
List<KeyValuePair<string, string>> param = new List<KeyValuePair<string, string>>();
param.Add(new KeyValuePair<string, string>("response_type","code"));
param.Add(new KeyValuePair<string, string>("client_id", "AB5********26"));
param.Add(new KeyValuePair<string, string>("scope", "com.intuit.quickbooks.accounting"));
param.Add(new KeyValuePair<string, string>("redirect_uri", "https://developer.intuit.com/v2/OAuth2Playground/RedirectUrl"));
var resp = httpClient.PostAsync("", new FormUrlEncodedContent(param)).GetAwaiter().GetResult();
var result = resp.Content.ReadAsStringAsync().GetAwaiter().GetResult();
我发送的请求的 HTML 响应..
<!DOCTYPE html>
<html class="dj_mac is-not-mobile" data-shell-type="node">
<!-- node-shell -->
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="google-site-verIfication" content="hiEXDzwqUxxMY5KZkAkeHBn6J0gy2Ne1gJdm77RkGbk">
<meta name="msapplication-TileColor" content="#0098cd">
<meta charset="utf-8" />
<link rel="preload"
href="https://plugin.intuitcdn.net/sbg-web-shell-ui/11.24.0/bower_components/document-register-element/build/document-register-element.js"
as="script">
<link rel="preload" href="https://plugin.intuitcdn.net/sbg-web-shell-ui/11.24.0/dojo/dojo.js" as="script">
<link rel="preload" href="https://plugin.intuitcdn.net/sbg-web-shell-ui/11.24.0/shell/boot.js" as="script">
<link rel="preload" href="https://plugin.intuitcdn.net/sbg-web-shell-ui/11.24.0/dojo/resources/blank.gif"
as="image">
<link rel="preload" href="https://plugin.intuitcdn.net/react-dom/16.9.0/umd/react-dom.production.min.js"
as="script">
<link rel="preload" href="https://plugin.intuitcdn.net/react/16.9.0/umd/react.production.min.js" as="script">
<script>
(function() {var e = document.createEvent("Event");e.initEvent("load", true, false);window.dispatchEvent(e);})();
</script>
<link rel="preload" href="https://plugin.intuitcdn.net/ua-parser-js/0.7.20/dist/ua-parser.min.js" as="script">
<meta id="viewPortMetaTag" name="viewport"
content="width=device-width, height=device-height, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=0">
<meta name="application-name" content="QuickBooks App Store">
<meta name="apple-mobile-web-app-title" content="QuickBooks App Store">
<title>QuickBooks App Store</title>
<script type="text/javascript" src="https://plugin.intuitcdn.net/sbg-web-shell-ui/11.24.0/dojo/dojo.js"></script>
</head>
<script type="text/javascript"
src="https://plugin.intuitcdn.net/sbg-web-shell-ui/11.24.0/bower_components/document-register-element/build/document-register-element.js">
</script>
</head>
<body class="en-us">
<script type="text/javascript" nonce="bTjY6kTz1OvXs0b/7WA0RA==">
try {
require({cache: {}});
require(["shell/base/loader", "shell/applications/default/config"], function(loader, config) {
var runtime = {"isWebpack":false,"embedded":false,"ecosystem":false,"accessDeniedPages":[48],"hiddenPages":[]};
loader.load({
useLayers: true,
storageSecondaryKey: "",
storagePrimaryKey: "",
platformPlugin: appContext.pluginsInfo && appContext.pluginsInfo.plugins ? appContext.pluginsInfo.plugins["qbo-ui-platform"] : null,
layers: config.getLayers(runtime)
}, config.getAppHandler(runtime));
});
} catch (error){
console.error(error);
require({cache: {}});
require(["shell/base/loader", "shell/applications/default/config"], function(loader, config) {
var runtime = {"isWebpack":false,"embedded":false,"ecosystem":false,"accessDeniedPages":[48],"hiddenPages":[]};
loader.load({
useLayers: true,
storageSecondaryKey: "",
storagePrimaryKey: "",
platformPlugin: appContext.pluginsInfo && appContext.pluginsInfo.plugins ? appContext.pluginsInfo.plugins["qbo-ui-platform"] : null,
layers: config.getLayers(runtime)
}, config.getAppHandler(runtime));
});
};
</script>
</body>
</html>
【问题讨论】:
-
通常要获取不记名令牌,您首先使用 REST 调用身份验证 API(即使用登录名和密码调用 Web 服务),然后它会返回不记名令牌。然后在后续调用中使用它。
-
您是否经历过并剖析了它的工作原理? developer.intuit.com/app/developer/qbo/docs/… 原样,您的问题不够详细,任何人都无法回答
-
@Nick.McDermaid 我修改了我的问题。请让我知道你的想法...
-
请在您的问题中添加 HTML 回复
-
@Nick.McDermaid 更新了答案中的 html 响应...
标签: c# oauth-2.0 console-application quickbooks-online