【问题标题】:The remote server returned an error: (401) Unauthorized. Twitter oAuth远程服务器返回错误:(401) Unauthorized。 Twitter oAuth
【发布时间】:2011-09-10 03:49:57
【问题描述】:

我正在尝试使用 twitterizer 进行 twitter oAuth,但我做不到。

我收到以下错误:

The remote server returned an error: (401) Unauthorized

当我的回调 url 是本地主机时。

如果我的回调 url 是 oob,对于 pin 流,它可以正常工作。

这是我的代码:

 public ActionResult LogOn(string returnUrl, bool? perm)
    {
        string consumerKeyTw = @"UF3F72XqfGShQs7juKMApA";
        string consumerSecretTW = "secret";
        OAuthTokenResponse requestToken = OAuthUtility.GetRequestToken(consumerKeyTw, consumerSecretTW, "http://localhost:58892/Twitterr/OAuth");

        // Direct or instruct the user to the following address:
        Uri authorizationUri = OAuthUtility.BuildAuthorizationUri(requestToken.Token);

        return new RedirectResult(authorizationUri.ToString(), false);
    }

我在设置回调 url 时从未获得令牌。在 Twitter 上,我注册了我的回调 url localhost。

我错过了什么吗?

知道发生了什么吗?

【问题讨论】:

    标签: c# asp.net-mvc-3 oauth twitterizer


    【解决方案1】:

    我遇到了同样的问题,并通过在 Twitter 应用程序设置页面中添加“回调 URL”来解决它。我还没有我的域名,所以我只是添加了一个未使用的域名,例如:http://www.website.com。 Twitterizer 请求调用立即开始为我工作。

    【讨论】:

      【解决方案2】:

      确保您的应用程序在 development portal 上设置为 Web 应用程序。对于那里的回调地址,请确保您使用了一个不正确的地址(如您的应用程序的主页),然后在运行时指定真实地址。

      Web 应用程序可以使用基于 pin 的身份验证,但桌面应用程序不能使用 Web 流。

      【讨论】:

      • 这是很常见的事情,所以不要觉得太糟糕。 :)
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-04-17
      • 1970-01-01
      • 2011-01-03
      • 1970-01-01
      相关资源
      最近更新 更多