Asp.net Yahoo,OAuth http请求。可在本地主机上工作,但不能在实时服务器上工作

Asp.net Yahoo,OAuth http请求。可在本地主机上工作,但不能在实时服务器上工作,asp.net,httpwebrequest,yahoo,Asp.net,Httpwebrequest,Yahoo,我有这个代码,正在尝试与雅虎认证!它在我的本地服务器上运行良好,但在我的实时服务器上发出的相同请求失败。当它调用GetResponse()时,返回一个(401)未经授权的错误。有人能帮我理解为什么吗?如果你需要更多信息,请告诉我 try { string url = "https://api.login.yahoo.com/oauth/v2/get_request_token?oauth_callback=" + Server.UrlEncode("http://www.dowdlefo

我有这个代码,正在尝试与雅虎认证!它在我的本地服务器上运行良好,但在我的实时服务器上发出的相同请求失败。当它调用
GetResponse()
时,返回一个(401)未经授权的错误。有人能帮我理解为什么吗?如果你需要更多信息,请告诉我

try
{
    string url = "https://api.login.yahoo.com/oauth/v2/get_request_token?oauth_callback=" + Server.UrlEncode("http://www.dowdlefolkart.com/extensions/contacts/webform1.aspx");
    url = GetUrl(url, consumerKey, consumerSecret);

    var req = System.Net.HttpWebRequest.Create(url);
    using (var res = req.GetResponse().GetResponseStream())
    {
        ....
    }
}
catch (Exception ex)
{
    Response.Write("ERROR" + ex.Message);
}
以下是完整的错误异常:

System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.Net.WebException: The remote server returned an error: (401) Unauthorized. 
at System.Net.HttpWebRequest.GetResponse() 
at NopSolutions.NopCommerce.Web.Extensions.Contacts.WebForm1.Page_Load(Object sender, EventArgs e) 
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) 
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) 
at System.Web.UI.Control.OnLoad(EventArgs e) 
at System.Web.UI.Control.LoadRecursive() 
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) 
at System.Web.UI.Page.HandleError(Exception e) 
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) 
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) 
at System.Web.UI.Page.ProcessRequest() 
at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) 
at System.Web.UI.Page.ProcessRequest(HttpContext context) 
at ASP.extensions_contacts_webform1_aspx.ProcessRequest(HttpContext context) 
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
更新:

我在费德勒身上发现了这个错误

oauth\u问题=timestamp\u拒绝&oauth\u可接受\u timestaps=1314119105-1314120305

所以看起来我的实时服务器的时间戳不正确。这就是我创建时间戳的方式:


string timestamp=Math.Floor((DateTime.UtcNow-new DateTime(1970,1,1)).TotalSeconds.ToString()

我发现了问题。错误的原因是时间戳无效。它只是比允许的稍大一点。使用Fiddler,我能够确定这个问题。错误是:
oauth\u problem=timestamp\u拒绝&oauth\u acceptable\u timestaps=1314119105-1314120305


然后我登录到我的实时服务器,并将系统时钟调整到所需的水平。显然是快了15分钟。一旦我调整了这个,错误就消失了。感谢Darin Dimitrov的帮助

你的实时服务器是否有代理?我不确定。如何检查?在live server的命令提示符下键入
ping www.yahoo.com
,或询问网络管理员。结果是:
ping any-fp3-real.wa1.b.yahoo.com[69.147.125.65]使用32字节的数据:从69.147.125.65回复:字节=32时间=8毫秒TTL=56从69.147.125.65回复:字节=32时间=8毫秒TTL=56从69.147.125.65回复:字节=32时间=7毫秒TTL=56从69.147.125.65回复:字节=32时间=9毫秒TTL=56 Ping 69.147.125.65统计:数据包:发送=4,接收=4,丢失=0(0%丢失),以毫秒为单位的近似往返时间:最小值=7ms,最大值=9ms,平均值=8ms
正确,因此没有代理服务器。你能发布你得到的全部异常堆栈跟踪吗?如果您可以跟踪请求,也会有所帮助。你可以用Fiddler来做这个。真的是因为时间戳吗?我有一个类似的问题,但我正在用桌面上的本地Java应用程序测试我的应用程序,我需要在哪里匹配时间戳?