Netlify Identity / GoTrue-js 用户 JWT 是否过期?
Netlify Identity / GoTrue-js do user JWT expire?
使用 https://github.com/netlify/gotrue-js 与 netlify 的身份验证服务(称为 "Identity")交互需要多长时间执行以下操作:
const user = auth.currentUser();
const jwt = user.jwt();
jwt
.then(response => console.log("This is a JWT token", response))
.catch(error => {
console.log("Error fetching JWT token", error);
throw error;
});
生成的 JWT 会永远有效吗?在用户登录会话期间?或者它会在给定的时间后过期吗?
通常 JWT
s 包含可以(可选)包含一个 exp
(到期)声明,其中包含到期时间。
我没有使用 GoTrue
的经验,但根据他们的 documentation you can configure the expiration,它设置为默认值 3600 秒。
由于该库还使用刷新令牌,因此您无需在令牌过期后再次重新进行身份验证,而是使用刷新令牌获取新的访问令牌。
使用 https://github.com/netlify/gotrue-js 与 netlify 的身份验证服务(称为 "Identity")交互需要多长时间执行以下操作:
const user = auth.currentUser();
const jwt = user.jwt();
jwt
.then(response => console.log("This is a JWT token", response))
.catch(error => {
console.log("Error fetching JWT token", error);
throw error;
});
生成的 JWT 会永远有效吗?在用户登录会话期间?或者它会在给定的时间后过期吗?
通常 JWT
s 包含可以(可选)包含一个 exp
(到期)声明,其中包含到期时间。
我没有使用 GoTrue
的经验,但根据他们的 documentation you can configure the expiration,它设置为默认值 3600 秒。
由于该库还使用刷新令牌,因此您无需在令牌过期后再次重新进行身份验证,而是使用刷新令牌获取新的访问令牌。