Search code examples
javascriptapilinkedin-api

Linkedin 403 Forbidden Error while getting connections email and name in JSApi


I'm trying to get email, name and picture from connections, but when the user authenticates, I get the error "GET https://api.linkedin.com/v1/people/~/connections:(picture-url,first-name,email-address)?count=30 403 (Forbidden) "

I'm posting my code below.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="http://platform.linkedin.com/in.js">
    api_key: uey3banalp6s
    authentication: true
</script>

<script type="text/javascript">

    function loadData() {
    IN.API.Connections("me")
    .fields(["pictureUrl","firstName","emailAddress"])
    .params({"count":30})
    .result(function(result) {
    profHTML = "";
    for (var index in result.values) {
    profile = result.values[index]
    if (profile.pictureUrl) {
    profHTML += "email:" + profile.emailAddress;
    profHTML += "name:" + profile.firstName;
    profHTML += "<img class=img_border height=30 align=\"left\" src=\"" + profile.pictureUrl + "\">";
    }
    }
    $("#connections").html(profHTML);
    });
    }

</script>
</head>

<body>
<div id="connections"></div>
    <script type="IN/Login" data-onAuth="loadData">
</script>
</body>
</html>

Solution

  • The API doesn't understand 'authentication: true'. It should be 'authorize: true'.

    <script type="text/javascript" src="http://platform.linkedin.com/in.js">
        api_key: uey3banalp6s
        authorize: true
    </script>