簡體   English   中英

Linkedin分享401未經授權

[英]Linkedin share 401 unauthorised

我從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,我也已將“ code(query string )”,而我已經嘗試過。但是卻收到相同的錯誤

OAuth測試控制台僅是OAuth 1.0。 oauth2_access_token是OAuth 2.0,並且不兼容。

無論如何,控制台的oauth_token是“訪問代碼”,應將其發布到https://api.linkedin.com/uas/oauth/accessToken api。 作為對您對accessToken請求的響應,您的accessToken將在“ oauth_token”字段和一個oauth_token_secret中。

然后,您可以創建一個共享。 控制台顯示的標題應添加到您的請求中,以接收access_token

請參閱文檔https://developer.linkedin.com/documents/getting-oauth-tokenhttps://developer.linkedin.com/documents/making-api-call-oauth-token來調用API

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM