使用 refresh_token 获取新的 id_token with Auth0 Lock 10 / Auth0.js 8?
Use refresh_token to obtain new id_token with Auth0 Lock 10 / Auth0.js 8?
我需要使用 refresh_token(我已存储)从 Auth0 获取新的 id_token。
在 Auth0 Lock 版本 9 中,有一种方法可以做到这一点 (as documented here):
lock.getClient().refreshToken(refresh_token, function (err, delegationResult) {
// Get here the new JWT via delegationResult.id_token
});
在Lock 10中,getClient()
不再存在,this page建议您可以实例化自己的auth0.js
实例。我该怎么做?
我试过这个:
return new auth0.WebAuth({
domain: '...',
clientID: '...'
});
但是这个对象似乎没有任何有用的方法。旧的 Auth0.js v7 库再次看起来清晰:
auth0.refreshToken(refresh_token, function (err, delegationResult) {
// Get here the new delegationResult.id_token
});
auth0.js v8 如何实现?
根据 available documentation 使用 Auth0.js v8 获取新令牌的方法是使用 renewAuth
方法。
The renewAuth
method allows you to acquire a new token from Auth0 for a user who is already authenticated against the hosted login page.
正如所指出的,renewAuth
似乎是执行此操作的新方法。但是,也可以对 Auth0 api 进行手动 HTTP 调用,以便使用刷新令牌获取新的 ID 令牌:
POST {yourAuth0Domain}/delegation
{
client_id: "...",
grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer",
refresh_token: "...",
scope: "openid app_metadata"
}
我需要使用 refresh_token(我已存储)从 Auth0 获取新的 id_token。
在 Auth0 Lock 版本 9 中,有一种方法可以做到这一点 (as documented here):
lock.getClient().refreshToken(refresh_token, function (err, delegationResult) {
// Get here the new JWT via delegationResult.id_token
});
在Lock 10中,getClient()
不再存在,this page建议您可以实例化自己的auth0.js
实例。我该怎么做?
我试过这个:
return new auth0.WebAuth({
domain: '...',
clientID: '...'
});
但是这个对象似乎没有任何有用的方法。旧的 Auth0.js v7 库再次看起来清晰:
auth0.refreshToken(refresh_token, function (err, delegationResult) {
// Get here the new delegationResult.id_token
});
auth0.js v8 如何实现?
根据 available documentation 使用 Auth0.js v8 获取新令牌的方法是使用 renewAuth
方法。
The
renewAuth
method allows you to acquire a new token from Auth0 for a user who is already authenticated against the hosted login page.
正如所指出的,renewAuth
似乎是执行此操作的新方法。但是,也可以对 Auth0 api 进行手动 HTTP 调用,以便使用刷新令牌获取新的 ID 令牌:
POST {yourAuth0Domain}/delegation
{
client_id: "...",
grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer",
refresh_token: "...",
scope: "openid app_metadata"
}