远程服务器返回错误:(401)未经授权.Twitter oAuth

elr*_*anu 10 c# oauth twitterizer asp.net-mvc-3

我正在尝试使用twitterizer与twitter oAuth合作,但我无法做到.

我收到以下错误:

The remote server returned an error: (401) Unauthorized.

当我的回调网址是本地主机时.

如果我的回调网址是oob,针对引脚流程它可以正常工作.

这是我的代码:

 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);
    }
Run Code Online (Sandbox Code Playgroud)

我在设置回调网址时从未获得令牌.在twitter上我注册了我的回调url localhost.

我错过了什么吗?

有什么想法吗?

Ric*_*ith 9

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

Web应用程序可以使用基于pin的身份验证,但桌面应用程序无法使用Web流.


gad*_*ssh 7

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

Fissh