【问题标题】:PassportJs is retrieving data with any clientID and clientSecretPassportJs 正在使用任何 clientID 和 clientSecret 检索数据
【发布时间】:2020-04-18 12:27:22
【问题描述】:

Google Plus 代币策略:

passport.use('googleToken', new GooglePlusTokenStrategy({
  clientID: 'adf',
  clientSecret: 'asdf'
}, (accessToken, refreshToken, profile, done) => {
  console.log(accessToken);
  console.log(profile);
  return done(false, profile)
}));

我从安卓客户端传递access_token 作为查询字符串。

accessTokenprofile 已使用任何 cliendId 和 clientSecret 成功检索!那么使用这些密钥的目的是什么?

顺便说一句,只有Android google plus 身份验证需要clientID,但服务器端(Nodejs)也需要clientSecret!但是这个clientSecret不是由google console为android凭据生成的

【问题讨论】:

  • 我的理解是需要有效的客户端 ID 和密码才能获得访问令牌。一旦访问令牌可用,它就会在没有客户端 ID 和密码的情况下使用。

标签: javascript node.js authentication ionic3 passport.js


【解决方案1】:

客户端 ID 和机密用于身份验证(以确保您是您所说的身份),而令牌用于授权(查看您有权访问哪些资源)。

accessToken 用于调用您在发出请求时包含在范围内的任何服务(Gmail、google map 或 youtube API)。 accessToken 是短暂的,因此一旦过期,您可以使用 refreshToken 再次请求 accessToken。

但是,如果您只是通过 oAuth 对用户进行身份验证,则可能根本不需要使用它们。

确保妥善保管它们,不要将它们泄漏到任何地方。

【讨论】:

    猜你喜欢
    • 2014-09-03
    • 1970-01-01
    • 2021-07-21
    • 2017-09-01
    • 1970-01-01
    • 2014-08-05
    • 2012-08-01
    • 2022-10-13
    • 2021-07-31
    相关资源
    最近更新 更多