0
我有一个移动应用程序与服务器进行通信。要在移动应用中进行身份验证,我正在使用Google登录。在返回符号的的accessToken我发送到我的服务器,并确认使用google-auth-library
作为这里建议:https://developers.google.com/identity/sign-in/web/backend-auth缓存Google JWT
import GoogleAuth from 'google-auth-library'
const auth = new GoogleAuth()
const client = new auth.OAuth2(MyClientId, '', '')
apiRoutes.use((req, res, next) => {
// get the token from the request
const token = req.token
if (token) {
// verify secret with google
client.verifyIdToken(token, MyClientId, (err, payload) =>
// proceed with the user authenticated
...
是否有必要做这样的判断与每一个用户发出请求?做一些缓存会是一个好习惯吗?或者在我的服务器上拥有自己的JWT实现,其中包含Google负载?
为了澄清,当你说“然后返回一个访问令牌”,并且“它可以被刷新”时,你指的是我的服务器发出的令牌,而不是Google发布的令牌? –