[英]Linkedin Api The remote server returned an error: (401) Unauthorized
我正在使用Linkedin Api。 在我的OAuthLinkedin.cs中,我有以下内容:
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
; 我的代码能够获得oauthToken,oauthTokenSecret
WebResponseGet(HttpWebRequest webRequest)是它失败的地方。 状态:System.Net.WebExceptionStatus.Protocol错误远程服务器返回错误:(401)未经授权。
在请求访问linkedin的权限后,它可以获得令牌秘密。 但我不确定这个未经授权的错误。 是一些许可问题。 我在哪里检查这个
谢谢孙
以下是您可以尝试确定问题根源的一些事项:
使用此OAuth测试控制台并将您生成的标头与此工具生成的标头进行比较: https : //developer.linkedin.com/oauth-test-console如果您的标头错误,那么LinkedIn将返回401状态
如果您在请求中将XML发布到LinkedIn,请确保内容类型(webRequest.ContentType)为“application / xml”而不是“application / x-www-form-urlencoded”,否则LinkedIn将返回401状态。
它也发生在我身上,但我弄清楚我做错了什么。
每当您创建签名时,令Token和TokenSecret为空。 它对我有用,因为它从浏览器请求获得旧的令牌和令牌秘密。
//Generate Signature
string sig = this.GenerateSignature(uri,
this.ConsumerKey,
this.ConsumerSecret,
this.Token,
this.TokenSecret,
method.ToString(),
timeStamp,
nonce,
out outUrl,
out querystring);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.