I've been working on getting Outbound Single Sign-on handshake to work with a ASP.NET application for quite a while now with no success.
The current error I'm getting is "timestamp_refused", how do I get this timestamp to be what NetSuite is expecting it to be?
Here is the C# code I use to generate the timestamp:
string TimeStamp = Convert.ToDouble( DateTime.Now.ToUniversalTime().Subtract( new DateTime(1970, 1, 1).ToUniversalTime()).TotalMilliseconds).ToString("#############");Here is the raw header I captured using Fiddler2 (notice the oauth_timestamp is different here than the one that netsuite is expecting):GET https://system.netsuite.com/app/common/integration/ssoapplistener.nl HTTP/1.1 User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Authorization: OAuth oauth_token="02076f140d6c0b036b7a5455503a6f0c064e56051a129c659c0de662b062", oauth_consumer_key="MyCorrectConsKey", oauth_signature_method="PLAINTEXT", oauth_signature="MyCorrectSign", oauth_timestamp="1294399981019", oauth_version="1.0", oauth_nonce="1192167183" Host: system.netsuite.com Connection: Keep-Alive
Here is the return WWW-Authenticate Header captured via Fiddler2:OAuth realm="https%3A%2F%2Facct-java027.svale.netledger.com", oauth_problem="timestamp_refused", oauth_acceptable_timestamps="1294417681420-1294418281420"
Here is the C# code I use to prepare the authorization header and call the ssoaplistener : HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://system.netsuite.com/app/common/integration/ssoapplistener.nl"); request.Method = "Get"; request.Timeout = 9000; Random rand = new Random(); string AuthHeader = ""; AuthHeader += " OAuth oauth_token="" + Token + "","; AuthHeader += " oauth_consumer_key="" + ConsumerKey + "", "; AuthHeader += " oauth_signature_method="PLAINTEXT","; AuthHeader += " oauth_signature="" + SharedSecrete + "","; AuthHeader += " oauth_timestamp="" + TimeStamp + "","; AuthHeader += " oauth_version="" + "1.0" + "","; AuthHeader += " oauth_nonce="" + rand.Next() + """; request.UserAgent = @Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8; request.Accept = @text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8; request.Headers.Add(HttpRequestHeader.Authorization, AuthHeader); HttpWebResponse Response = (HttpWebResponse)request.GetResponse();