LinkedIn JavaScript SDK "You must specify a valid JavaScript API Domain as part of this key's configuration."
Asked Answered
L

1

0

I want to show our LinkedIn company recent updates inside our web site. so i follow these steps, to integrate with LinkedIn JavaScript SDK @ https://developer.linkedin.com/docs/getting-started-js-sdk . mainly i did the following steps:-

1- I created a new application .

2- then i add the following domains inside the "Valid SDK Domains". since the site i want to show the linkedin data inside it is a sharepoint online site which has the following url https://ourcompanyname.sharepoint.com :-

enter image description here

3- then inside my sharepoint page , i added the following script, to get the information from LinkedIn:-

<script type="text/javascript" src="//platform.linkedin.com/in.js">
    api_key:   0**********c
</script>
<script>
alert("1");
    var liLogin = function() { // Setup an event listener to make an API call once auth is complete
        IN.UI.Authorize().params({"scope":["r_basicprofile", "r_emailaddress"]}).place();
        IN.Event.on(IN, 'auth', getProfileData);
    }

    var getProfileData = function() { // Use the API call wrapper to request the member's basic profile data
    alert("2");
        IN.API.Profile("me").fields("id,firstName,lastName,email-address,picture-urls::(original),public-profile-url,location:(name)").result(function (me) {
            var profile = me.values[0];
            var id = profile.id;
            var firstName = profile.firstName;
            var lastName = profile.lastName;
            var emailAddress = profile.emailAddress;
            var pictureUrl = profile.pictureUrls.values[0];
            var profileUrl = profile.publicProfileUrl;
            var country = profile.location.name;
            alert(id);
        });
    }
</script>


<p>testing</p>

but on the browser i got the following error:-

Error: You must specify a valid JavaScript API Domain as part of this key's configuration. userspace:22:9
<anonymous>
https://www.linkedin.com/uas/js/userspace:22:9
<anonymous>
https://www.linkedin.com/uas/js/userspace:1:2

EDIT Now based on @Lars Hendriks advice, i waited for 2 hours and i can see that the You must specify a valid JavaScript API Domain as part of this key's configuration. error is no longer showing inside my browser F12 console. but at the same time i can not see any data returned from the JavaScript call, even the alert("2") & alert(id) inside my above JavaScript did not get popup.. not sure what is going on ?

Lymphoid answered 23/10, 2018 at 14:31 Comment(0)
S
1

what you could try is :

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

if this does not work , you might want to have to wait :

After registering an API key and specifying a valid domain, it may take up to 30 minutes for the changes to take affect, so if it doesn't work immediately, go grab a coffee and check back in a few.

Septal answered 24/10, 2018 at 11:16 Comment(11)
thanks for the reply.. what does this website URL refer to ? i added our Linkedin profile url inside it .. but seems i need to add our sharepoint online site url ?Lymphoid
i just looked it up and i am incorrect that has no influence on the proces. so it can be anything you want.Septal
now after 2 hours the "“You must specify a valid JavaScript API Domain as part of this key's configuration.”" error is no longer showing inside my browser F12 console. but at the same time i can not see any data returned from the JavaScript call, even the alert("2") & alert(id) inside my javascript will not get popup-ed up .. not sure what is going on ??Lymphoid
the only thing i can imagine going wrong is that you are not getting authenticated.Septal
thanks the reply. Now In my case i don't want users to be already authenticated to LinkedIn to be able to view the Recent Updates inside our external web site. As we are building an external web site for our company, so we can't assume that any user who visits our site is already login to LinkedIn, and the user maybe doesn't even have a LinkedIn account. so seems the LinkedIn JavaScript SDK is not the right appraoch to follow in my case? what do you think? as in my case i want to get the Recent Updates (which are available to public users) without any authentication in advance.Lymphoid
well i think you have some misperceptions about oauth. there are different ways of authentication. the best for you would be the Client credential oauth flow. this means you use the client ID and client Secret of the application in the developer page. so a user does not have to authenticate themself because the application already authenticated himself. but please note that this way of authentication requires you to get an partnership with linkedin and i am not sure if this will work with the javascript SDK.Septal
now regardless of the partnership with linked, in my case i need to do the integration using JavaScript, so i do not think i should expose the client secret inside my JavaScript is this correct? or this is not an issue?Lymphoid
you shouldn't expose those keys, because people can post things on your links page with those. but there a several ways to do this safe if you just google what fits your solution the best.Septal
i am totally confused on how to achieve what i am looking for inside LinkedIn API & SDK. the main 2 restrictions in my case are 1) I need to do the integration using JavaScript (client side), i do not have the ability to do the integration on the server side. 2) i need to get the Recent Updates without having the users to be login to LinkedIn. now if i need to send the Client Secret, then i can not expose this using JavaScript?, and if the JavaScript SDK requires users to be already login to LinkedIn then this SDK will not work for me .. so not sure which approach i can follow?Lymphoid
you wont be able to do this only client-side. atleast it i have never been able to do this only client-side.Septal
OK i see, i though it will be possible to get the LinkedIn's Recent Updates without so many complexity, at-least since those Recent Updates are provided for public users,, so an RSS feed could have been sufficient for me... but seems in LinkedIn there is not a simple way to get those Recent Updates..Lymphoid

© 2022 - 2024 — McMap. All rights reserved.