【问题标题】:How do I connect to OAuth in C#?如何在 C# 中连接到 OAuth?
【发布时间】:2012-08-06 17:31:39
【问题描述】:

对于一个项目,我正在尝试创建一个不使用令牌的消费者角色。

我已经设法在代码隐藏中创建了所需的详细信息:

        string outUrl = "";
    string querystring = "";

    string consumerKey = "";
    string consumerSecret = "";
    Uri uri = new Uri("");

    oAuthBase2 oAuth = new oAuthBase2();
    string nonce = oAuth.GenerateNonce();
    string timeStamp = oAuth.GenerateTimeStamp();

    string sig = oAuth.GenerateSignature(uri, consumerKey, consumerSecret, string.Empty, string.Empty,
        "POST", timeStamp, nonce, oAuthBase2.SignatureTypes.HMACSHA1, out outUrl,
        out querystring);

我从这里去哪里?

【问题讨论】:

  • 你为什么尝试使用令牌?令牌是在随后的握手中关联请求来自谁的唯一方式。
  • 好的,我开始建立理解了。基本上,我正在尝试使用像这篇文章link 这样的devdefined oauth 来使用2 腿oauth 方法,但是数据需要包含一个用户ID 和要签名的数据。对于我的生活,我无法弄清楚如何使用额外的参数对其进行签名
  • DNOA 允许您将内容放入 ExtraData[] 参数中。我不知道 DevDefined 是否有。为什么要受限于 DevDefined?
  • 因为根据 LTI 标准,用户在使用时会被重定向到外部来源和他们的需求。
  • 所以他们的网站说您必须使用特定的 OAuth 库?头脑。吹。

标签: c# .net oauth


【解决方案1】:

您的第一站应该是OAuth specification。它准确地解释了每个步骤的用途。如果你想要一个使用 DotNetOpenAuth 的 OAuth 示例(很容易成为 .NET 最完整的 OAuth 库),我有 included one here

DotNetOpenAuth 源代码还包含连接到 Facebook、Twitter 和 Google 的示例。

【讨论】:

    【解决方案2】:

    DOtNetOpenAuth 过于复杂,不利于初学者理解 OAuth 对话框。对于在客户端使用 OAuth 的小项目,让我建议 RestSharp 这很简单,不是最好的,但至少你知道你在做什么。 Here is a sample of code to get you started。我希望这会有所帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-05-09
      • 2012-01-26
      相关资源
      最近更新 更多