I am trying to log the user in programatically using LinkedIn Javascript SDK. I am not using the default flow (which includes the button as a script) as we need a custom size button, so here is my code:
//inside head...
<script type="text/javascript" src="//platform.linkedin.com/in.js">
api_key: 'XXXXXXXXXXXX'
credentials_cookie: true
</script>
//inside some script tag
function loginWithLinkedIn() {
IN.User.authorize(linkedInLoginCallback); //yeah I have that method
}
However, as soon as call loginWithLinkedIn
, I'm getting an error telling IN.User
is undefined. IN
itself is defined, but has only ENV
and Event
fields defined. How can I initiate LinkedIn login using JS (not a button/script tag)? I couldn't find any useful documentation anywhere, and LinkedIn's own documentation is terrible.
I was having the same issue. For me it was because we had changed the subdomain location of our application from www. to app. This change required me to go into the LinkedIn developer console and under the Javascript
tab add our new app location to the list of Valid SDK Domains.