linkedin-apilinkedin-jsapi

linkedin javascript SDK suddenly stopped working without showing any error


I have created an app to achieve login-with-linked-in functionality. Previously it worked fine, but all of a sudden it stopped working.

Previously if the user had already logged-in to LinkedIn, clicking the login-in-with-linkedIn button will lead the user to there the corresponding dashboard, otherwise login-popup opens and user details get saved in the db and the user redirects to the corresponding dashboard, But now nothing happening.

Note:- I have used my custom button to use this functionality. not the linked-in provided button code.

Here are my code and app creation steps:-

Button code:-

<a href="javascript:void(0);" onclick="doLinkedInLoginForBuyer()" class="btn btn--social-li"><?php echo Labels::getLabel('LBL_Linkedin',$siteLangId);?></a>

Javascript SDK code:-

<script type="text/javascript" src="//platform.linkedin.com/in.js">
    api_key:*********
   authorize:true
</script>
<script>
    function doLinkedInLoginForBuyer(){
       IN.User.authorize(function(){
           onLinkedInAuth();
       });
    }
    function onLinkedInAuth() {
        IN.API.Profile("me").fields("email-address","first-name","id").result(function (data) {
            processLinkedInUserDetails(data);
        }).error(function (data) {
            $.systemMessage('There was some problem in authenticating your account with LinkedIn,Please try with different login option','alert alert--danger'); 
        });
    }
    processLinkedInUserDetails = function(data){
        data = data.values[0];
        fcom.ajax(fcom.makeUrl('LinkedIn', 'loginLinkedIn'), data, function(t) {
            var response = JSON.parse(t);
            if(response.status ==0){
                $.systemMessage(response.msg,'alert alert--danger');  
            }
            if(response.status ==1){
                location.href = response.msg;
            }
        });
    };
</script>

Note:- It seems that onLinkedInAuth() as well as processLinkedInUserDetails() functions are not called at all now. Previously they worked fine.

Let me know if any other details are required. Thanks!


Solution

    1. After a long discussion with LinkedIn Customer Support they just said that they didn't support API-related issues. They asked to buy a premium account for any kind of technical support

    2. Also I come to know that they stopped giving support for Javascript SDK.

    Check here:- JavaScript SDK is not currently supported

    enter image description here

    Solution:- Now I followed the below post and make it work:

    https://www.codexworld.com/login-with-linkedin-using-php/

    1. Visit LinkedIn Developers page and log in with your LinkedIn account credentials.

    2. Click the Create app button to create a new LinkedIn app.

    3. Provide the information about your app and click Create an app to submit the app registration form.

       App name – Name of the application.
      
       Company – Name of your company.
      
       App description – Workflow of the application.
      
       App logo – Logo to display on the OAuth dialog.
      
       Privacy policy URL – URL of the Privacy Policy page.
      
       Business email – Your email address.
      
       Products – Select the products that you’d like to add to your app.
      
    4. On successful app creation, the page will be redirected to the App settings screen.

    5. Switch to the Auth tab » Scroll down to OAuth 2.0 settings section.

      Specify the redirect URL in the Redirect URLs fields and Update the App settings.

      Note: The Redirect URLs must be matched with the Redirect URL that is specified in the script.

    6. In the Application credentials section, you will see the Client ID and Client Secret of your LinkedIn App. The App ID and App secret need to be specified in the script at the time of the LinkedIn API call.

    Now you have to create PHP code that will call linked-in API with the help of Client ID and Client Secret.

    Kindly check Php code of thread for example.