【问题标题】:TypeError: OAuthStrategy requires a consumerKey optionTypeError:OAuthStrategy 需要一个 consumerKey 选项
【发布时间】:2020-06-06 22:22:09
【问题描述】:

当我将 twitter OAuth 添加到我的应用程序时,我不断收到此错误。我目前有 google OAuth 可以正常工作,但添加 twitter 会导致错误。在之前所有关于此错误的帖子中,我都没有看到可行的解决方案;有人可以帮忙吗?这是 twitter 的代码 sn-p - 它与 google 的代码相同。

passport.use(
  new TwitterStrategy({
      twitterclientID: keys.twitterclientID,
      twitterclientSecret: keys.twitterclientSecret,
      callbackURL: '/auth/twitter/callback',
      proxy: true
    }

【问题讨论】:

    标签: twitter oauth


    【解决方案1】:

    twitterclientID 替换为consumerKey & 将twitterclientSecret 替换为consumerSecret

    最近 google 也做了同样的事情,所以你也需要为 google 更新,因为你使用的是 google oauth

    passport.use(
      new TwitterStrategy({
          consumerKey: theClientID,
          consumerSecret: theClientSecret,
          callbackURL: '/auth/twitter/callback',
          proxy: true
        }
    

    【讨论】:

      【解决方案2】:
      passport.use(
        new TwitterStrategy({
            consumerKey: keys.twitterclientID,
            consumerSecret: keys.twitterclientSecret,
            callbackURL: '/auth/twitter/callback',
            proxy: true
          }
      

      【讨论】:

        【解决方案3】:

        我已经声明了consumerKeyconsumerSecret。我的问题是,用作两个键的值的环境变量没有定义。

        如果您使用 netlify,运行 netlify link 后问题可能会得到解决。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2017-03-31
          • 2013-04-12
          • 1970-01-01
          • 2019-01-04
          • 2013-11-15
          • 1970-01-01
          相关资源
          最近更新 更多