使用 devdefined 构建签名 [英] build a signature using devdefined

查看:57
本文介绍了使用 devdefined 构建签名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将现有应用程序从 QBXML 转换为 QuickBooks Online 帐户使用 QBOE API V3.我已经设法完成了 OAuth 并使用 DevDefined 工具包获得了看似有效的令牌/秘密.我被困在 oauth_signature 的生成上.所有文档都指向我使用 Intuit.Ipp DLL,但是我不能,因为它是写入 .net 4.0 框架并且我的应用程序运行的服务器只加载了 2.0.我可以移动我的应用程序,但测试升级会使我在截止日期(2014 年 4 月 16 日)之后.有没有一种方法可以使用 DevDefined 或其他一些选项来构建签名?

I am converting an existing application from QBXML to use the QBOE API V3 for the QuickBooks Online accounts. I have managed to complete the OAuth and have what appears to be valid tokens/secrets using the DevDefined toolkit. I am stuck on generation of the oauth_signature. All the documentation points me to use the Intuit.Ipp DLL's however I can't because it is written to .net 4.0 framework and the server my application runs on only has 2.0 loaded. I can move my application but testing that upgrade would put me after the cut off deadline (4/16/2014). Is there a way I can build the signature using the DevDefined or some other option?

该应用程序在 IIS 6.0、DotNet Framework 2.0 和 ASP.VB 上运行.

The application runs on IIS 6.0, DotNet Framework 2.0, with ASP.VB.

推荐答案

现在是 4/16 截止吗?我没有看到任何地方宣布.我以为是 3/15.

Is the cutoff 4/16 now? I didn't see that announced anywhere. I thought it was 3/15.

我没有在 .NET 2.0 上测试过这个,但这只是使用 DevDefined 而没有所有开销.它将为您处理签名和 http 请求.

I haven't tested this on .NET 2.0 but this just uses DevDefined without all the overhead. It will handle the signing and the http request for you.

using System.Text;
using DevDefined.OAuth.Consumer;
using DevDefined.OAuth.Framework;
// etc...

    public void doGet()
    {
        IOAuthSession session = CreateSession();
        string resp = session.Request().Get().ForUrl("https://quickbooks.api.intuit.com/v3/company/"
                + realmId + "/query?query=select * from customer where DisplayName='" + name + "'").ToString();
    }

    public void doPost(string Name)
    {
        IOAuthSession session = CreateSession();
        string reqBody = "<Customer xmlns=\"http://schema.intuit.com/finance/v3\" domain=\"QBO\" sparse=\"false\">";
        reqBody += "<DisplayName>" + Name + "</DisplayName>";
        reqBody += "</Customer>";
        byte[] bytes = Encoding.UTF8.GetBytes(reqBody);

        session.ConsumerContext.UseHeaderForOAuthParameters = true;
        IConsumerRequest req = session.Request().WithRawContentType("application/xml").WithRawContent(bytes);
        req = req.WithAcceptHeader("application/xml");
        req = req.ForUrl("https://quickbooks.api.intuit.com/v3/company/"
                + realmI + "/customer");
        string resp = req.Post().ToString();
    }

    private IOAuthSession CreateSession()
    {
        OAuthConsumerContext consumerContext = new OAuthConsumerContext
        {
            ConsumerKey = Properties.Settings.Default.consumerKey,
            ConsumerSecret = Properties.Settings.Default.consumerSecret,
            SignatureMethod = SignatureMethod.HmacSha1
        };
        IOAuthSession session = new OAuthSession(consumerContext);
        session.AccessToken = myAccessToken;
        return session;
    }

这篇关于使用 devdefined 构建签名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆