3

There seems to be a bug with the LinkedIn JS SDK. You're able to reproduce with the code they supply in the "Getting Started" section of the docs.

<!DOCTYPE html>
<html>
<head>
    <title>LinkedIn test</title>

    <script>
        // Setup an event listener to make an API call once auth is complete
        function onLinkedInLoad() {
            IN.Event.on(IN, "auth", getProfileData);
        }

        // Handle the successful return from the API call
        function onSuccess(data) {
            console.log(data);
        }

        // Handle an error response from the API call
        function onError(error) {
            console.log(error);
        }

        // Use the API call wrapper to request the member's basic profile data
        function getProfileData() {
            IN.API.Raw("/people/~").result(onSuccess).error(onError);
        }
    </script>
    <script type="text/javascript" src="//platform.linkedin.com/in.js">
        api_key: [API_KEY]
        onLoad: onLinkedInLoad
    </script>

</head>
<body>

<script type="in/Login"></script>

</body>
</html>

If you put this code on a non-https site and hit that URL on iOS Safari, clicking the "sign in with LinkedIn" button will initiate authorization, but the 'auth' callback will never fire. Instead, you'll get a CORS error in the console:

"Uncaught SecurityError: Blocked a frame with origin "https://platform.linkedin.com" from accessing a frame with origin ..."

All other environments seem to work fine (e.g. Chrome, FF, IE, Desktop Safari, Android browsers, etc.). I'm also able to reproduce the issue if I set the user agent to an iOS device in Chrome's dev tools, which makes me think the JS SDK is doing user-agent sniffing.

Is there a workaround? Is the LinkedIn dev team aware of this issue? Did I miss a Monday detail?

PS This is probably related: Sign in with Linkedin doesn't trigger callback on iOS Safari when using the JS API

degrassesagan
  • 83
  • 1
  • 7

2 Answers2

2

According to LinkedIn's Getting Started with the JavaScript SDK page, the LinkedIn JavaScript SDK doesn't support iOS 5+.

Note: The JavaScript SDK is not compatible with iOS 5+.

Tasos K.
  • 7,979
  • 7
  • 39
  • 63
Jeff Miller
  • 2,405
  • 1
  • 26
  • 41
0

@degrassesagan I think you need to do the following:

function onLinkedInLoad() {
  IN.Event.on(IN,"auth",getProfileData);
  IN.Event.on(IN,"success",onSuccess);
  IN.Event.on(IN,"error",onError);
}

There is also a side issue, I have discovered, in relation to the LinkedIn JS SDK. I am using mobile Safari 10.3.3, and although the login business logic executes correctly, the URL flow does not. After a successful login, the page goes to a LinkedIn 'Page Not Found' page, rather than closing the current browser tab, to reveal the owner's page underneath?

I am not sure whether this is connected to the original question or not, but I would be grateful, if anyone could shine a light on this problem.

Charles Robertson
  • 1,760
  • 16
  • 21