Note that there are some explanatory texts on larger screens.

plurals
  1. POHaving trouble implementing Yahoo BOSS v2 with OAuth in .net/C#
    text
    copied!<p>I've been trying to create a simple search page using the Yahoo BOSS v2 api, but cant get OAuth to work properly. I have all the keys etc, and downloaded a C# class for OAuth at <a href="http://oauth.googlecode.com/svn/code/csharp/OAuthBase.cs" rel="nofollow">http://oauth.googlecode.com/svn/code/csharp/OAuthBase.cs</a> , but I keep getting errors.</p> <p>We've tried the following:</p> <p>a javascript function builds a yahoo boss query string and then leads to PageMethods.getYahoo(query string, responseFunction);</p> <p>Here's the code behind</p> <pre><code>[WebMethod] public static string getYahoo(string url) { String result; OAuthBase oauth = new OAuthBase(); Uri uri = new Uri("http://mysite.com"); string a, qstring = ""; string signature = oauth.GenerateSignature(uri, "-my consumer key-", "-my secret-", out a, out qstring); url = url.Replace("{oauth}", qstring + "oauth_signature=" + signature); WebResponse objResponse; WebRequest objRequest = System.Net.HttpWebRequest.Create(url); objResponse = objRequest.GetResponse(); using (StreamReader sr = new StreamReader(objResponse.GetResponseStream())) { result = sr.ReadToEnd(); sr.Close(); } return result; } </code></pre> <p>here is my GenerateSignature method in oAuthBase class:</p> <pre><code>public string GenerateSignature(Uri url, string consumerKey, string consumerSecret, out string normalizedUrl, out string normalizedRequestParameters) { normalizedUrl = null; normalizedRequestParameters = null; string signatureBase = GenerateSignatureBase(url, consumerKey,null ,null,null,GenerateTimeStamp(),GenerateNonce(), HMACSHA1SignatureType, out normalizedUrl, out normalizedRequestParameters); HMACSHA1 hmacsha1 = new HMACSHA1(); hmacsha1.Key = Encoding.ASCII.GetBytes(string.Format("{0}&amp;{1}", UrlEncode(consumerSecret), "")); return GenerateSignatureUsingHash(signatureBase, hmacsha1); } </code></pre> <p>But we keep getting the error:</p> <pre><code>Message: Sys.Net.WebServiceFailedException: The server method 'getYahoo' failed with the following error: System.Net.WebException-- The remote server returned an error: (401) Unauthorized. Line: 6934 Char: 21 Code: 0 </code></pre> <p>I hope someone here can help...!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload