Category Archives: OAuth

[RESOLVED] The remote server returned a error 401: unauthorized Status: System.Net.WebExceptionStatus.ProtocolError

Hi folks,

In my linkedin oauth 1.0,

I am getting this error

The remote server returned a error 401: unauthorized

Status: System.Net.WebExceptionStatus.ProtocolError

 public string WebResponseGet(HttpWebRequest webRequest)
{
StreamReader responseReader = null;
string responseData = "";

try
{
responseReader = new StreamReader(webRequest.GetResponse().GetResponseStream());
responseData = responseReader.ReadToEnd();
}
catch
{
throw;
}
finally
{
webRequest.GetResponse().GetResponseStream().Close();
responseReader.Close();
responseReader = null;
}

return responseData;
}

Hi,

Which protocol you are using to communicate ? Also can you let us know what is there on the server side. Is it a WCF service or something else ?

Hi Sudeep_13

The code uses SS13 protocol

  webRequest = System.Net.WebRequest.Create(url) as HttpWebRequest;
//webRequest.ContentType = "text/xml";
webRequest.Method = method;
webRequest.Credentials = CredentialCache.DefaultCredentials;
webRequest.AllowWriteStreamBuffering = true;

webRequest.PreAuthenticate = true;
webRequest.ServicePoint.Expect100Continue = false;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;

webRequest.Headers.Add("Authorization", "OAuth realm=\"http://api.linkedin.com/\",oauth_consumer_key=\"" + this.ConsumerKey + "\",oauth_token=\"" + this.Token + "\",oauth_signature_method=\"HMAC-SHA1\",oauth_signature=\"" + HttpUtility.UrlEncode(sig) + "\",oauth_timestamp=\"" + timeStamp + "\",oauth_nonce=\"" + nonce + "\",oauth_verifier=\"" + this.Verifier + "\", oauth_version=\"1.0\"");

I am not using WCF. It connects to linkedin, my application  once granted "Allow" permission connects to linkedin

Thank you
Sun

Hi,

<div sizcache="7" sizset="16">

Are you trying to access some files/folders from your asp.net application.

Try giving full permissions to AppPool in IIS. It should do the trick.

 You can change your AppPool Identity (which has full permissions). or change permissions which should be in advanced settings

</div>