4

我正在尝试实施 Google OAuth Passport.js 策略,但由于缺乏文档和示例,我似乎无法回答某些问题。

出于安全和技术原因,我的应用程序使用承载而不是 cookie。

passport-google-oauth GitHub 页面上提供的单个示例没有解释某些事情,例如:

  • 在这种情况下,承载策略实现如何替换 cookie?
  • 如何获取 Google 令牌的过期时间?
  • 我应该如何处理accessTokenrefreshToken

我真的不想使用 cookie,因为这会创建第二个授权系统,它是已经存在的承载策略的副本。

这个问题可以应用于其他护照 OAuth 策略,如 Twitter 和 Facebook。

4

1 回答 1

4

I managed to find all the answers needed in this excellent blog post:

http://jeroenpelgrims.com/token-based-sessionless-auth-using-express-and-passport/

and the corresponding source code:

https://bitbucket.org/resurge/sessionless-token-auth-with-express/src/6e94c2ea59591e75b074ff6acc89442065d33007/app.js?at=master

Thanks to Jeroen Pelgrims!

于 2014-09-24T15:59:30.343 回答