繁体   English   中英

IN.User.Authorize 回调从未触发

[英]IN.User.Authorize callback never fired

从今天起,我们使用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 年 01 月 28 日,错误再次出现。

尝试用 window.IN.user.authorize 替换 window.IN.User.authorize

window.IN.user.authorize正在返回一个 promise,并且在登录成功后执行成功回调。 如果我们用用户替换用户,它很奇怪但有效

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 !");
                });   

试试这个代码。 我做了一些改变并且对我来说工作正常。 需要将 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>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM