Reputation: 913
I created an application in linkedin developers and set OAuth 2.0 redirect urls as http://localhost:8080/
and http://localhost:8080/myProject/
. Then I wrote <script>
in <head>
section:
<script type="text/javascript" src="//platform.linkedin.com/in.js">
api_key: 86g3tbk6gy0y56
onLoad: liLogin()
authorize: yes
</script>
Also I wrote one more <script>
at the bottom of the page:
<script>
var liLogin = function() {
IN.UI.Authorize().params({"scope":["r_basicprofile", "r_emailaddress"]}).place();
IN.Event.on(IN, 'auth', getProfileData);
}
var getProfileData = function() {
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(firstName + " " + lastName);
});
}
</script>
Then I create an <a>
tag for calling the liLogin
function.
<a onClick="liLogin()">Linkedin</a>
Uncaught Error: You must specify a valid JavaScript API Domain as part of > this key's configuration. at userspace?v=0.0.2000-RC8.60429- 1429&apiKey=86g3vbk6gy0y56&onLoad=liLogin()&authorize=yes&secure=1&:22 at userspace?v=0.0.2000-RC8.60429- 1429&apiKey=86g3vbk6gy0y56&onLoad=liLogin()&authorize=yes&secure=1&:31
Above error occurs when I run the application.
Also, if I write configuration with ""
, then linkedin login page appears, but the content is uh oh
.
<script type="text/javascript" src="//platform.linkedin.com/in.js">
'api_key': '86g3tbk6gy0y56',
'onLoad': 'liLogin()',
'authorize': 'yes'
</script>
How can I make linkedin configuration?
Upvotes: 3
Views: 1878
Reputation: 21
For some reason LinkedIn does not recognize "localhost" as a valid redirect URI. So I suggest you use the actual domain name when you test your website in dev environment. Just add the following line to your host file:
127.0.0.1 YOUR SITE DOMAIN
Upvotes: 1