在quickbook在线集成中获取parameter_rejected错误

时间:2017-08-29 06:55:31

标签: c# .net asp.net-mvc

我已经完成了这段代码:

static void Main (string[] args)
    {
        Console.WriteLine("Authenticating..");
        string consumerkey = "L0ORES0pf0uEody1YDI3sTkTpyBGaDVVnVRBb1krprkrghPWLQ";
        string consumerSecret = "NAONcYrwGgpkFCJN2BgXZHjG8YLqn1JWMEPDXIMg";
        string REQUEST_TOKEN_URL = "https://oauth.intuit.com/oauth/v1/get_request_token";
        string ACCESS_TOKEN_URL = "https://oauth.intuit.com/oauth/v1/get_access_token";

        string OauthLink = "https://developer.intuit.com/v2/OAuth2Playground/RedirectUrl";
        var consumerContext = new OAuthConsumerContext
        {
            ConsumerKey = consumerkey,
            ConsumerSecret = consumerSecret,
            SignatureMethod = SignatureMethod.HmacSha1
        };
        IOAuthSession AuthSession = new OAuthSession(consumerContext,REQUEST_TOKEN_URL, OauthLink, ACCESS_TOKEN_URL);
        IToken requestToken = AuthSession.GetRequestToken();

    }

我收到错误:未处理的类型' DevDefined.OAuth.Framework.OAuthException'发生在DevDefined.OAuth.dll中附加信息:parameter_rejected

我附上了错误的屏幕截图。

enter image description here

什么是在线快速阅读请求令牌URL和OAuth 2.0的访问令牌URL?

1 个答案:

答案 0 :(得分:0)

Oauth2.0 //通过WebClient刷新并获取新的访问令牌,并为CRUD操作构建ServiceContext

访问令牌每60分钟过期

        string URI = "https://oauth.platform.intuit.com/oauth2/v1/tokens/bearer";
        string myParameters = "grant_type=refresh_token&refresh_token=L0115-----------------------------------"; // Put Refresh Token

        WebClient wc = new WebClient();
        wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
        wc.Headers[HttpRequestHeader.Accept] = "application/json";
        wc.Headers[HttpRequestHeader.Authorization] = "Basic UT------------------------------hcW5SV---------------------Qg==";  // Add Auth Token
        string HtmlResult = wc.UploadString(URI, myParameters);
        wc.Dispose();

        var jobject = JsonConvert.DeserializeObject<Test>(HtmlResult);


        string accessToken = jobject.access_token;


        string relmid = "123412341234123421341234";  // Relmid 

        OAuth2RequestValidator oauthValidator = new OAuth2RequestValidator(accessToken);
        ServiceContext serviceContext = new ServiceContext(relmid, IntuitServicesType.QBO, oauthValidator);
        serviceContext.IppConfiguration.BaseUrl.Qbo = "https://sandbox-quickbooks.api.intuit.com/";
        //serviceContext.IppConfiguration.BaseUrl.Qbo = "https://quickbooks.api.intuit.com/";//prod
        serviceContext.IppConfiguration.MinorVersion.Qbo = "23";

        CustomerCRUD.CustomerAddTestUsingoAuth(serviceContext);

        CustomerCRUD.CustomerFindAllTestUsingoAuth(serviceContext);