У меня есть этот код, который пытается аутентифицироваться в Yahoo! Он отлично работает на моем локальном сервере, но тот же запрос на моем работающем сервере не выполняется. Он возвращается с (401) несанкционированной ошибкой при вызове GetResponse()
. Может кто-нибудь помочь мне понять, почему? Дайте мне знать, если вам нужна дополнительная информация.
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)
Обновление:
Я получаю эту ошибку с Fiddler.
oauth_problem=timestamp_refused&oauth_acceptable_timestamps=1314119105-1314120305
Так что, похоже, моя временная метка с живого сервера неверна. Вот как я создаю метку времени:
string timestamp = Math.Floor((DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds).ToString();