Linkedin REST API Auth and JSAPI call, Rails/Omniauth

1.4k views Asked by At

I lost my temper few days ago because of this simple problem. Can you help me on this?

I'm suppose, since it's written in the Linkedin JS API documentation here, to be able to logion with REST and launch calls with JSAPI : https://developer.linkedin.com/documents/inauth-inevent-and-inui

Authorization Tokens

While the easiest method of authenticating a user for the JSAPI is to use one of the login buttons, some sites have implemented the OAuth 1.0a flow used by the REST API. Whichever type of authentication you use for the user, the JSAPI will recognize that the member has already logged in, as long as the key and hostname are the same. This happens automatically, requiring no additional code by the developer.

But this is NOT working, I have this weird console error :

Cannot call method 'Profile' of undefined

when I call this right after REST auth:

IN.API.Profile("me").fields(["id", "..."]).result(linkedin_connect_save);

Any ideas?

2

There are 2 answers

1
Kirsten Jones On BEST ANSWER

That console error doesn't have anything to do with authentication - I'm guessing you're loading another javascript framework which is interfering with the LinkedIn framework and the IN object isn't getting properly loaded.

The following page works with a key that I've previously authenticated using REST in the same browser here: http://developer.linkedinlabs.com/tutorials/testing.html

<html>
<head>
  <title>Connections App Example</title>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body class="yui3-skin-sam  yui-skin-sam">
<script type="text/javascript" src="http://platform.linkedin.com/in.js">
  api_key: MY_API_KEY
  onLoad: loadData
  authorize: true
</script>
<script type="text/javascript">
function loadData() {
IN.API.PeopleSearch()
       .fields("firstName", "lastName", "distance", "publicProfileUrl","pictureUrl")
       .params({"keywords": "princess", "count": 10, "sort": "distance"})
       .result(function(result) {
           alert(JSON.stringify(result));
});
}
</script>
</body>
</html>
0
sandeep On

your code might call before js load.. include js before ur code..