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:
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.
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