IN.User.Authorize回调从未触发

时间:2018-11-15 16:20:26

标签: linkedin linkedin-api linkedin-jsapi linkedin-j

从今天开始,我们使用linkedin Javascript SDK进行身份验证的应用程序停止工作。 我们意识到对https://platform.linkedin.com/in.js的呼叫现在重定向到https://platform.linkedin.com/xdoor/scripts/in.js

因此,对IN.User.Authorize(callbackFunction)的调用成功打开了身份验证对话框窗口,但不再触发该回调。

此外,在我们应用程序的另一部分中,我们使用IN.UI.Authorize.place().onWindowRemove.subscribe(callbackFunction)来跟踪对话框的关闭。此功能还停止了措词,现在使用URL invalid://打开一个新窗口,控制台将引发以下错误:

jSecure Error: URL should be absolute with allowed schemas, relative, a hash fragment or query string. TODO?client_id=XXXX&type=user-agent in.js:7
​
jSecure Error: URL should be absolute with allowed schemas, relative, a hash fragment or query string. invalid://?xdOrigin=https%3A%2F%2FXXX-XXX&xdChannel=XXXX&xd_origin_host=https%3A%2F%2FXXXX.XXXX in.js:7 
​
jSecure Error: URL should be absolute with allowed schemas, relative, a hash fragment or query string. TODO?client_id=XXXX&type=user-agent

您对为什么它停止工作有想法吗?

编辑:错误于2019年1月28日重新出现。

2 个答案:

答案 0 :(得分:1)

尝试将window.IN.User.authorize替换为window.IN.user.authorize

window.IN.user.authorize 返回一个Promise,并在登录成功后执行成功回调。如果我们将User替换为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 !");
                });   

答案 1 :(得分:0)

尝试此代码。我做了一些更改,并为我正常工作。需要将window.IN.User.authorize()替换为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>