10

我正在尝试使用 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。

我错过了什么吗?

知道发生了什么吗?

4

2 回答 2

9

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

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

于 2011-06-07T15:30:33.233 回答
7

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

于 2012-08-18T18:55:15.983 回答