【问题标题】:Fetch LinkedIn Data using JS givs error "message": "Unknown authentication scheme"使用 JS 获取 LinkedIn 数据 givs 错误“消息”:“未知身份验证方案”
【发布时间】:2018-10-11 18:53:34
【问题描述】:

我已按照此示例 https://www.c-sharpcorner.com/blogs/fetch-linkedin-data-using-javascript 从特定公司获取更新/帖子等数据。

我收到以下错误。

{ “错误代码”:0, "message": "未知的认证方案", "requestId": "MXRLWYPBNU", “状态”:401, “时间戳”:1539160527230 }

公司已将我的个人资料添加为公司管理员,因此我应该获得身份验证才能获取数据。

我做错了什么? 好的,这是我的代码:`

<script type="text/javascript" src="https://platform.linkedin.com/in.js">
api_key: 8616po0krrhh2k
scope: r_basicprofile r_emailaddress
onLoad: onLinkedInLoad,
</script>


$(document).ajaxSend(function (event, jqxhr, settings) {
if (settings.url == "https://www.linkedin.com/uas/oauth/authenticate") {
    settings.url = "https://www.linkedin.com/uas/oauth/authorize"
}});

function onLinkedInLoad() {
IN.Event.on(IN, "auth", onLinkedInAuth());}

function onSuccess(data) {
console.log(data); }


function onError(error) {
console.log(error);
}
function onLinkedInAuth() {
var cpnyID = 86104; //the Company ID for which we want updates
IN.API.Raw("/companies/" + cpnyID + "/updates?event-type=status- 
update&start=0&count=10&format=json").result(displayCompanyUpdates);

console.log("After auth");
}

function displayCompanyUpdates(result) {
var div = document.getElementById("displayUpdates");
var el = "<ul>";
var resValues = result.values[0];
for (var i in resValues) {
var share = resValues[i].updateContent.companyStatusUpdate.share;
    var isContent = share.content;
    var isTitled = isContent,
        isLinked = isContent,
        isDescription = isContent,
        isThumbnail = isContent,
        isComment = isContent;
    if (isTitled) {
        var title = isContent.title;
    } else {
        var title = "News headline";
    }
    var comment = share.comment;
    if (isLinked) {
        var link = isContent.shortenedUrl;
    } else {
        var link = "#";
    }
    if (isDescription) {
        var description = isContent.description;
    } else {
        var description = "No description";
    }

    if (share) {
    var content = "< a target = '_blank' href = " + link + " > " + comment + " 
    </a><br>";

     el += "<li><div>" + content + "</div></li>";
    }
    console.log(share);
}
 el += "</ul>";
 document.getElementById("displayUpdates").innerHTML = el;
}




<div id="displayUpdates"></div>`

【问题讨论】:

  • 向我们展示您的代码,该链接不是一个好的来源,因为我们无法查看您是否犯了错误。
  • 好的,我在下面的答案中添加了我的代码。
  • 你能不能修改一下你的linkedin开发者账号有哪些权限?
  • 您的意思是我的应用程序中的“默认应用程序权限”吗?
  • 是的,你都有吗?

标签: linkedin linkedin-api


【解决方案1】:

我在您的代码中看到的一个明显问题是,您为要进行的调用添加了错误的范围。

对于公司 API 调用,您需要以下范围:rw_company_admin

【讨论】:

    猜你喜欢
    • 2013-09-09
    • 2013-06-08
    • 1970-01-01
    • 1970-01-01
    • 2021-06-21
    • 1970-01-01
    • 2021-11-17
    • 1970-01-01
    • 2021-09-21
    相关资源
    最近更新 更多