IN.User.Authorize callback never fired

前端 未结 2 1172
天命终不由人
天命终不由人 2020-12-30 12:46

Since today, our application that uses the linkedin javascript SDK to authenticate users stopped working. ​ We realized that the call to https://platform.linkedin.com/in.js

相关标签:
2条回答
  • 2020-12-30 13:25

    Try replacing window.IN.User.authorize with window.IN.user.authorize

    window.IN.user.authorize is returning a promise and success callback is executed post login success. Its weird but working if we replace User with user

    window.IN.user.authorize().then(function(data){
                        console.log("Logged in successfully .");
                        window.IN.API.Raw("/people/~:(id,first-name,last-name,formatted-name,headline,location,industry,current-share,num-connections,num-connections-capped,summary,specialties,positions,picture-url,site-standard-profile-request,api-standard-profile-request,public-profile-url,email-address)").method("GET").body().result(function (oData) {
                            that.props.dispatch(userCreation(linkedInProfileFormat(oData)));
                        });
                    },function(error){
                        alert("Linkedin failed because of harshita !");
                    });   
    
    0 讨论(0)
  • 2020-12-30 13:45

    Try this code. I did some changes and working fine for me. need to replace window.IN.User.authorize() TO window.IN.user.authorize()

      <script type="text/javascript" src="//platform.linkedin.com/in.js">
                api_key: XXXXXXXXX
                authorize: true
    
            </script>
    
            <script type="text/javascript">
    
            function liAuth(){
            window.IN.user.authorize().then(function(){
            getProfileData();
            });
            }
            function setLoginBadge(profile) {
                    if (!profile) {
                    profHTML = "<p>You are not logged in</p>";
                    }                       
                    document.getElementById("given_name").value = profile.firstName;
                    document.getElementById("family_name").value = profile.lastName;
                    document.getElementById("email").value = profile.emailAddress;
                    document.getElementById("verifyOauthRequestLinkedIn").submit();
                    }
    
    
            function onError(error) {
            console.log(error);
            }
    
            function getProfileData() {
            IN.API.Profile("me")
            .fields(["id", "firstName", "lastName", "pictureUrl", "publicProfileUrl","email-address","headline"])
            .result(function(result) {
            setLoginBadge(result.values[0]);
                    })
            .error(onError);
            }
    
            </script>
    
            <a href="#"><img onclick="liAuth()" src="/images/linkedIn.png"></a>
    
    0 讨论(0)
提交回复
热议问题