IN.User.Authorize callback never fired
Asked Answered
S

2

7

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 now redirects to https://platform.linkedin.com/xdoor/scripts/in.js.

​ Consequently, calls to IN.User.Authorize(callbackFunction) successfully opens the authentication dialog window but the callback is never fired anymore. ​

Also, in another part of our application we are using the IN.UI.Authorize.place().onWindowRemove.subscribe(callbackFunction) to track dialog closes. This feature has also stopped wording and now opens a new window with the url invalid:// and the console throws this error: ​

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

​ ​ Do you have an idea on why this stopped working ?

EDIT: Bug reappeared as of 2019 01 28.

Szechwan answered 15/11, 2018 at 16:20 Comment(7)
We are having the same issues, along with many others errors that were previously working. We have not made code changes on our end, but a lot of functionality is currently broken. The sdk code has changed quite a bit this week, which you can see through the web archive web.archive.org/web*/platform.linkedin.com/in.jsHyacinth
I'm receiving this error message: "Unhandled Promise Rejection: TypeError: null is not an object (evaluating 'this.self.location.replace')" which points to line 1434 in in.js and the offending code: ` return l()(e, t), a()(e, [{ key: "reload", value: function() { this.self.location.replace(P.call(this)), D.call(this) } }]), e `Sunshinesunspot
same issue here. same error as @tupakapoor.Airlift
This appears to be working now!Sunshinesunspot
Same issue right now, just appeared on Jan 28th, 2018, was working prior.Ipswich
Same issue. Anyone got the solution to this. ?Estranged
@M.J Check my answer.Genetics
G
1

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 !");
                });   
Genetics answered 30/1, 2019 at 15:15 Comment(0)
A
0

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>
Albatross answered 6/2, 2019 at 6:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.