我正在从https://developer.linkedin.com/oauth-test-console获取访问令牌,我正在从标题文本框中获取“oauth_token”。
当我尝试使用上述令牌时,我得到“远程服务器返回错误:(401)未经授权。” 我正在使用下面的代码。
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)
{
}
即使我已经尝试使用 https://www.linkedin.com/uas/oauth2/authorization?response_type=code &client_id=YOUR_API_KEY &scope=r_basicprofile%20r_emailaddress &state=STATE &redirect_uri=YOUR_REDIRECT_URI 从这个 URL 我已经采取了“代码(查询字符串)”,我已经试过了。但得到同样的错误