![](/img/trans.png)
[英]Sign in with Linkedin doesn't trigger callback on iOS Safari when using the JS API
[英]Unable to authorize with LinkedIn JS SDK on iOS Safari from non-https url
LinkedIn JS SDK似乎有一個錯誤。 您可以使用他們在文檔的“入門”部分中提供的代碼進行復制。
<!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,則單擊“使用LinkedIn登錄”按鈕將啟動授權,但“auth”回調將永遠不會觸發。 相反,您將在控制台中收到CORS錯誤:
“Uncaught SecurityError:阻止帶原點的框架” https://platform.linkedin.com “訪問具有原點的框架......”
所有其他環境似乎都運行良好(例如Chrome,FF,IE,桌面Safari,Android瀏覽器等)。 如果我將用戶代理設置為Chrome的開發工具中的iOS設備,我也能夠重現這個問題,這讓我覺得JS SDK正在進行用戶代理嗅探。
有解決方法嗎? LinkedIn開發團隊是否意識到這個問題? 我錯過了星期一的細節嗎?
PS這可能是相關的: 在使用JS API時,使用Linkedin登錄不會觸發iOS Safari上的回調
根據LinkedIn的JavaScript SDK入門頁面,LinkedIn JavaScript SDK不支持iOS 5+。
注意:JavaScript SDK與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的“找不到頁面”頁面,而不是關閉當前的瀏覽器選項卡,以顯示下面的所有者頁面?
我不確定這是否與原始問題有關,但如果有人能夠對這個問題發表意見,我將不勝感激。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.