C# Linkedin共享401未经授权
我从标题文本框中获取“oauth_令牌”获取访问令牌 当我尝试使用上面的toke时,我得到了“远程服务器返回了一个错误:(401)未经授权。” 我正在使用下面的代码C# Linkedin共享401未经授权,c#,asp.net,linkedin,C#,Asp.net,Linkedin,我从标题文本框中获取“oauth_令牌”获取访问令牌 当我尝试使用上面的toke时,我得到了“远程服务器返回了一个错误:(401)未经授权。” 我正在使用下面的代码 try { string xml = "<share> <comment>Check out the LinkedIn Share API!</comment> <content> <title>LinkedIn Developers D
try
{
string xml = "<share> <comment>Check out the LinkedIn Share API!</comment> <content> <title>LinkedIn Developers Documentation On Using the Share API</title>";
xml += "<description>Leverage the Share API to maximize engagement on user-generated content on LinkedIn</description>";
xml += "<submitted-url>https://developer.linkedin.com/documents/share-api</submitted-url>";
xml += " <submitted-image-url>http://m3.licdn.com/media/p/3/000/124/1a6/089a29a.png</submitted-image-url> </content> <visibility>";
xml += " <code>anyone</code> </visibility></share>";
string accessCodeUri = "http://api.linkedin.com/v1/people/~/shares?oauth2_access_token=generated token"; // this is session value which you get on authorization success return by linkedin
WebRequest request = WebRequest.Create(accessCodeUri);
request.Method = "POST";
request.ContentType = "application/xml";
request.ContentLength = xml.Length;
StreamWriter requestWriter = new StreamWriter(request.GetRequestStream(), System.Text.Encoding.ASCII);
requestWriter.Write(xml);
requestWriter.Close();
WebResponse webResponse = request.GetResponse();
//success
}
catch (WebException exc)
{
}
连我都试过了
&客户端\u id=您的\u API\u密钥
&范围=r\u基本配置文件%20r\u电子邮件地址
&状态=状态
&重定向\u uri=您的\u重定向\u uri
从这个URL中,我得到了“代码(查询字符串)”并尝试了。但是得到了相同的错误,OAuth测试控制台仅为OAuth 1.0。oauth2_访问_令牌是oauth2.0,它们不兼容 无论如何,控制台的oauth_令牌是应该发布到api的“访问代码”。作为对accessToken请求的响应,accessToken将位于“oauth_token”字段和oauth_token_secret中 然后您可以创建一个共享。控制台显示的头应该添加到您的请求中,以接收访问令牌 请参阅文件
要调用API我现在遇到了同样的问题,当我在一个原始数据库中多次授权应用程序时。linkedin在调用api时只会出现401错误;等待10秒或更长时间后,新的accesstoken工作正常;