使用 LinkedIn 登录 Authorize Promise Undefined
SignIn With LinkedIn Authorize Promise Undefined
我最近开始在使用 Linkedin 登录功能时遇到问题。我收到以下错误:
Uncaught TypeError: Cannot read property 'then' of undefined at Object.authorize (in.js:18)
我在我的应用程序的 OAuth 2.0 设置中正确定义了我的重定向 URL。
我的 LinkedIn 应用程序中列出了以下权限:
- r_emailaddress
- w_share
- r_basicprofile
- r_liteprofile
- rw_company_admin
- w_member_social
这是我的代码:
<script type="application/javascript">
//This will be re-defined where it is needed
var linkedInAPILoaded = function(){};
</script>
<script type="text/javascript" src="https://platform.linkedin.com/in.js">
api_key: ${apiKey}
authorize: true
onLoad: linkedInAPILoaded
lang: en_US
</script>
<form name="li_signin" class="li_signin" action="<c:url value='/signin/linkedin'/>" method="post">
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
<a id="linkedInIcon" href="javascript:;" aria-label="<spring:message code="oa.social.linkedin.login"/>">
<i class="glyphicon glyphicon-refresh gly-spin hidden"></i>
<img src="<c:url value='/images/In-2C-48px-R.png'/>" alt="<spring:message code='oa.social.linkedin.signin.link' />" />
</a>
</form>
<script type="text/javascript">
var linkedInIcon = $('#linkedInIcon');
function callbackFunction() {
$('#profileOverlay').addClass('hidden');
$('#loadingOverlay').removeClass('hidden');
linkedInIcon.blur();
linkedInIcon.find('.gly-spin').removeClass('hidden');
linkedInIcon.find('img').addClass('hidden');
linkedInIcon.closest('form').submit();
}
linkedInIcon.on('click', function() {
IN.User.authorize(callbackFunction, window);
callbackFunction();
});
这是来自 LinkedIn 的 in.js 的相关功能:
authorize: function(t, n) {
return t = t ? t.bind(n || window) : function() {}
,
e().credentials.isAuthenticated ? (t(),
!0) : (e().authorize().then(t),
!1)
},
第 5 行的 e().authorize() 未定义。
我不确定此问题是否与 LinkedIn API 升级到 2.0 有关,或者作为授权功能的一部分返回的承诺是否存在同步问题。真的不知道为什么会这样以及如何解决它。
我也 运行 关注这个问题,在四处搜索了一段时间后,结果发现他们正在弃用整个 Javascript SDK。以下是来自 here
的一些相关引述
Authentication, SDKs, and Plugins: We are also deprecating several obsolete or seldomly-used products and technologies.
Authentication: We will sunset OAuth 1.0 and require all developers to use OAuth 2.0, which we have supported since 2013. OAuth 2.0 is the industry standard and widely-used by the majority of people building on our platform.
SDKs: Our JavaScript and Mobile Software Development Kits (SDKs) will stop working. Developers will need to migrate to using OAuth 2.0 directly from their apps.
Plugins: Several website plugins, which were used for generating drop-in code that could quickly add enhanced LinkedIn functionality to websites, will no longer be available for use. Specifically, the Member Profile, Company Profile, Company Insider, Jobs You May Be Interested In (JYMBII), and Alumni Tool plugins will all be deprecated.
遗憾的是,似乎没有我们可以使用的直接替代品
我最近开始在使用 Linkedin 登录功能时遇到问题。我收到以下错误:
Uncaught TypeError: Cannot read property 'then' of undefined at Object.authorize (in.js:18)
我在我的应用程序的 OAuth 2.0 设置中正确定义了我的重定向 URL。
我的 LinkedIn 应用程序中列出了以下权限:
- r_emailaddress
- w_share
- r_basicprofile
- r_liteprofile
- rw_company_admin
- w_member_social
这是我的代码:
<script type="application/javascript">
//This will be re-defined where it is needed
var linkedInAPILoaded = function(){};
</script>
<script type="text/javascript" src="https://platform.linkedin.com/in.js">
api_key: ${apiKey}
authorize: true
onLoad: linkedInAPILoaded
lang: en_US
</script>
<form name="li_signin" class="li_signin" action="<c:url value='/signin/linkedin'/>" method="post">
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
<a id="linkedInIcon" href="javascript:;" aria-label="<spring:message code="oa.social.linkedin.login"/>">
<i class="glyphicon glyphicon-refresh gly-spin hidden"></i>
<img src="<c:url value='/images/In-2C-48px-R.png'/>" alt="<spring:message code='oa.social.linkedin.signin.link' />" />
</a>
</form>
<script type="text/javascript">
var linkedInIcon = $('#linkedInIcon');
function callbackFunction() {
$('#profileOverlay').addClass('hidden');
$('#loadingOverlay').removeClass('hidden');
linkedInIcon.blur();
linkedInIcon.find('.gly-spin').removeClass('hidden');
linkedInIcon.find('img').addClass('hidden');
linkedInIcon.closest('form').submit();
}
linkedInIcon.on('click', function() {
IN.User.authorize(callbackFunction, window);
callbackFunction();
});
这是来自 LinkedIn 的 in.js 的相关功能:
authorize: function(t, n) {
return t = t ? t.bind(n || window) : function() {}
,
e().credentials.isAuthenticated ? (t(),
!0) : (e().authorize().then(t),
!1)
},
第 5 行的 e().authorize() 未定义。
我不确定此问题是否与 LinkedIn API 升级到 2.0 有关,或者作为授权功能的一部分返回的承诺是否存在同步问题。真的不知道为什么会这样以及如何解决它。
我也 运行 关注这个问题,在四处搜索了一段时间后,结果发现他们正在弃用整个 Javascript SDK。以下是来自 here
的一些相关引述Authentication, SDKs, and Plugins: We are also deprecating several obsolete or seldomly-used products and technologies.
Authentication: We will sunset OAuth 1.0 and require all developers to use OAuth 2.0, which we have supported since 2013. OAuth 2.0 is the industry standard and widely-used by the majority of people building on our platform.
SDKs: Our JavaScript and Mobile Software Development Kits (SDKs) will stop working. Developers will need to migrate to using OAuth 2.0 directly from their apps.
Plugins: Several website plugins, which were used for generating drop-in code that could quickly add enhanced LinkedIn functionality to websites, will no longer be available for use. Specifically, the Member Profile, Company Profile, Company Insider, Jobs You May Be Interested In (JYMBII), and Alumni Tool plugins will all be deprecated.
遗憾的是,似乎没有我们可以使用的直接替代品