[英]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.