4

I recently began having issues with my Signin With Linkedin functionality. I get the following error:

Uncaught TypeError: Cannot read property 'then' of undefined at Object.authorize (in.js:18)

I do have my redirect urls correctly defined in my apps' OAuth 2.0 settings.

My LinkedIn App has the following permissions listed in it:

  • r_emailaddress
  • w_share
  • r_basicprofile
  • r_liteprofile
  • rw_company_admin
  • w_member_social

Here is my code:

<script type="application/javascript">
    //This will be re-defined where it is needed
    var linkedInAPILoaded = function(){};
</script>

<script type="text/javascript" src="https://platform.linkedin.com/in.js">
    api_key:    ${apiKey}
    authorize:  true
    onLoad:     linkedInAPILoaded
    lang:       en_US
</script>

<form name="li_signin" class="li_signin" action="<c:url value='/signin/linkedin'/>" method="post">
    <input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
    <a id="linkedInIcon" href="javascript:;" aria-label="<spring:message code="oa.social.linkedin.login"/>">
        <i class="glyphicon glyphicon-refresh gly-spin hidden"></i>
        <img src="<c:url value='/images/In-2C-48px-R.png'/>" alt="<spring:message code='oa.social.linkedin.signin.link' />" />
    </a>
</form>

<script type="text/javascript">
    var linkedInIcon = $('#linkedInIcon');

    function callbackFunction() {
        $('#profileOverlay').addClass('hidden');
        $('#loadingOverlay').removeClass('hidden');
        linkedInIcon.blur();
        linkedInIcon.find('.gly-spin').removeClass('hidden');
        linkedInIcon.find('img').addClass('hidden');
        linkedInIcon.closest('form').submit();
    }

    linkedInIcon.on('click', function() {
        IN.User.authorize(callbackFunction, window);
        callbackFunction();
    });

Here is the relevant function from LinkedIn's in.js:

authorize: function(t, n) {
    return t = t ? t.bind(n || window) : function() {}
    ,
    e().credentials.isAuthenticated ? (t(),
    !0) : (e().authorize().then(t),
    !1)
},

And it is the e().authorize() on line 5 that is undefined.

I'm not sure if this issue is related to LinkedIn's API upgrade to 2.0 or if there is some synchronicity issue with the promise returned as a part of the authorize function. Really as a loss as to why this started and how to fix it.

dukedevil294
  • 1,285
  • 17
  • 31
  • Have any solution to this? Also facing the same error. I have also noticed that the following functions have an empty body. They do nothing. A promise should have been returned from these functions. Our best chance is linking to an older version of https://platform.linkedin.com/in.js function e() { return t.user || { credentials: {}, logout: function() {}, refresh: function() {}, authorize: function() {} } } – vcaz konzam Apr 12 '19 at 15:33
  • @vcaz-konzam Unfortunately I haven't found a solution and have not received much help on here either. I agree with what you're seeing about the empty functions though. Do you know where there are older versions of in.js that I could link to? That at least might help give me a better of understanding of what's happening. – dukedevil294 Apr 12 '19 at 20:34
  • Sorry, unable to find any older version of the JS. I am following https://learn.microsoft.com/en-us/linkedin/shared/authentication/authorization-code-flow?context=linkedin/compliance/context and using the flow suggested here. – vcaz konzam Apr 15 '19 at 11:09

1 Answers1

4

I ran into this issue too and after searching around for a while, it turns out they're deprecating the entire Javascript SDK. Here are some relevant quotes from here

Authentication, SDKs, and Plugins: We are also deprecating several obsolete or seldomly-used products and technologies.

  • Authentication: We will sunset OAuth 1.0 and require all developers to use OAuth 2.0, which we have supported since 2013. OAuth 2.0 is the industry standard and widely-used by the majority of people building on our platform.

  • SDKs: Our JavaScript and Mobile Software Development Kits (SDKs) will stop working. Developers will need to migrate to using OAuth 2.0 directly from their apps.

  • Plugins: Several website plugins, which were used for generating drop-in code that could quickly add enhanced LinkedIn functionality to websites, will no longer be available for use. Specifically, the Member Profile, Company Profile, Company Insider, Jobs You May Be Interested In (JYMBII), and Alumni Tool plugins will all be deprecated.

Sadly it appears that there is no direct replacement that we can use

Community
  • 1
  • 1
Tom Prats
  • 7,364
  • 9
  • 47
  • 77