无法从非 https url 在 iOS Safari 上使用 LinkedIn JS SDK 进行授权

Unable to authorize with LinkedIn JS SDK on iOS Safari from non-https url

LinkedIn JS SDK 似乎存在错误。您可以使用他们在文档的 "Getting Started" 部分提供的代码进行重现。

<!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>

如果您将此代码放在非 https 站点上并在 iOS Safari 上点击 URL,点击 "sign in with LinkedIn" 按钮将启动授权,但 'auth' 回调永远不会触发。相反,您会在控制台中收到 CORS 错误:

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

所有其他环境似乎都能正常工作(例如 Chrome、FF、IE、Desktop Safari、Android 浏览器等)。如果我在 Chrome 的开发工具中将用户代理设置为 iOS 设备,我也能够重现该问题,这让我认为 JS SDK 正在执行用户代理嗅探。

有解决办法吗? LinkedIn 开发团队是否知道这个问题?我错过了星期一的细节吗?

PS 这大概是相关的:

根据 LinkedIn 的 Getting Started with the JavaScript SDK 页面,LinkedIn JavaScript SDK 不支持 iOS 5+。

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

@degrassesagan 我认为您需要执行以下操作:

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

我发现还有一个与 LinkedIn JS SDK 有关的附带问题。我使用的是移动版 Safari 10.3.3,虽然登录业务逻辑正确执行,但 URL 流程却没有。 成功登录后,页面转到 LinkedIn 'Page Not Found' 页面,而不是关闭当前浏览器选项卡,以显示下面所有者的页面?

我不确定这是否与原始问题有关,但如果有人能解决这个问题,我将不胜感激。