gpt4 book ai didi

javascript - 使用 LinkedIn 登录授权 promise 未定义

转载 作者:行者123 更新时间:2023-12-04 02:18:22 24 4
gpt4 key购买 nike

我最近开始遇到我的 Signin With Linkedin 功能的问题。我收到以下错误:
Uncaught TypeError: Cannot read property 'then' of undefined at Object.authorize (in.js:18)
我确实在我的应用程序的 OAuth 2.0 设置中正确定义了我的重定向 URL。

我的 LinkedIn 应用程序中列出了以下权限:

  • r_email地址
  • 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 有关,或者作为授权函数的一部分返回的 promise 是否存在同步问题。对于为什么会开始以及如何解决它,真的是一种损失。

    最佳答案

    我也遇到了这个问题,在搜索了一段时间后,事实证明他们正在弃用整个 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.


    可悲的是,似乎没有我们可以使用的直接替代品

    关于javascript - 使用 LinkedIn 登录授权 promise 未定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55640221/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com