我正在尝试从任何地方的 QuickBooks 连接到 QuickBooks 桌面,但是,我看不到我的 QuickBooks 桌面实例,Joe's Test Company。我只看到我的 QuickBooks Online 实例。
我相信问题是我的网址:
https://qbo.intuit.com/qbo1/rest/user/v2/
QuickBooks Desktop 的基本 URL 是什么?
这是我的代码:
public void GetAccessTokenAndSecret()
{
string oauth_callback_url = HttpContext.Current.Request.RawUrl;
oauth_callback_url = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + oauth_callback_url;
string consumerKey = _qboSettings.ConsumerKey;
string consumerSecret = _qboSettings.ConsumerKeySecret;
var oauthLink = Constants.OauthEndPoints.IdFedOAuthBaseUrl;
IToken token = (IToken)HttpContext.Current.Session["requestToken"];
IOAuthSession session = CreateSession();
IToken requestToken = session.GetRequestToken();
HttpContext.Current.Session["requestToken"] = requestToken;
string RequestToken = requestToken.Token;
string TokenSecret = requestToken.TokenSecret;
oauthLink = Constants.OauthEndPoints.AuthorizeUrl + "?oauth_token=" + RequestToken + "&oauth_callback=" + UriUtility.UrlEncode(oauth_callback_url);
HttpContext.Current.Response.Redirect(oauthLink);
}
/// <summary>
/// Creates Session
/// </summary>
/// <returns>Returns OAuth Session</returns>
protected IOAuthSession CreateSession()
{
OAuthConsumerContext consumerContext = new OAuthConsumerContext
{
ConsumerKey = _qboSettings.ConsumerKey,
ConsumerSecret = _qboSettings.ConsumerKeySecret,
SignatureMethod = SignatureMethod.HmacSha1
};
return new OAuthSession(consumerContext,
Constants.OauthEndPoints.IdFedOAuthBaseUrl + Constants.OauthEndPoints.UrlRequestToken,
Constants.OauthEndPoints.IdFedOAuthBaseUrl,
Constants.OauthEndPoints.IdFedOAuthBaseUrl + Constants.OauthEndPoints.UrlAccessToken);
}
这是我的常数:
using System.Globalization;
namespace HelloIntuitAnywhere.Utilities
{
using System.Configuration;
using System.Web;
/// <summary>
/// Contains Constants.
/// </summary>
internal class Constants
{
static string Url_Request_Token = "/get_request_token";
static string Url_Access_Token = "/get_access_token";
static string Intuit_OAuth_BaseUrl ="https://oauth.intuit.com/oauth/v1";
static string Intuit_Workplace_AuthorizeUrl = "https://workplace.intuit.com/Connect/Begin";
static string BlueDot_AppMenuUrl = "https://workplace.intuit.com/api/v1/Account/AppMenu";
static string DisconnectUr = "https://appcenter.intuit.com/api/v1/Connection/Disconnect";
static string oauth_callback_url = HttpContext.Current.Request.RawUrl.Replace("Configure", "OAuthHandler");
static string menuProxy = "MenuProxy.aspx";
static string grantUrl = "OauthGrant.aspx";
static string qbo_base_url = "https://qbo.intuit.com/qbo1/rest/user/v2/";
static string openid_identifier = "https://openid.intuit.com/Identity-YourAppName";
/// <summary>
/// OAuth EndPoints.
/// </summary>
internal class OauthEndPoints
{
/// <summary>
/// Url Request Token
/// </summary>
internal static string UrlRequestToken = Url_Request_Token != null ?
Url_Request_Token.ToString(CultureInfo.InvariantCulture) : "/get_request_token";
/// <summary>
/// Url Access Token
/// </summary>
internal static string UrlAccessToken = Url_Access_Token != null ?
Url_Access_Token.ToString(CultureInfo.InvariantCulture) : "/get_access_token";
/// <summary>
/// Federation base url.
/// </summary>
internal static string IdFedOAuthBaseUrl = Intuit_OAuth_BaseUrl != null ?
Intuit_OAuth_BaseUrl.ToString(CultureInfo.InvariantCulture) : "https://oauth.intuit.com/oauth/v1";
/// <summary>
/// Authorize url.
/// </summary>
internal static string AuthorizeUrl = Intuit_Workplace_AuthorizeUrl != null ?
Intuit_Workplace_AuthorizeUrl.ToString(CultureInfo.InvariantCulture) : "https://workplace.intuit.com/Connect/Begin";
}
/// <summary>
/// Intuit Anywhere Endpoints.
/// </summary>
internal class IaEndPoints
{
/// <summary>
/// BlueDot Menu Url.
/// </summary>
internal static string BlueDotAppMenuUrl = BlueDot_AppMenuUrl != null ?
BlueDot_AppMenuUrl.ToString(CultureInfo.InvariantCulture) : "https://workplace.intuit.com/api/v1/Account/AppMenu";
/// <summary>
/// Disconnect url.
/// </summary>
internal static string DisconnectUrl = DisconnectUrl != null ?
DisconnectUrl.ToString(CultureInfo.InvariantCulture) : "https://appcenter.intuit.com/api/v1/Connection/Disconnect";
}
}
}