gpt4 book ai didi

c# - 远程服务器返回错误 : (401) Unauthorized. Twitter oAuth

转载 作者:可可西里 更新时间:2023-11-01 09:02:20 25 4
gpt4 key购买 nike

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

我收到以下错误:

远程服务器返回错误:(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 时从未获得 token 。在 Twitter 上,我注册了我的回调 url localhost。

我错过了什么吗?

知道发生了什么吗?

最佳答案

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

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

关于c# - 远程服务器返回错误 : (401) Unauthorized. Twitter oAuth,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6267096/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com