只能获取长访问令牌或刷新令牌
Can only get either a long access token or a refresh token
我正在使用 react-native-auth0 sdk。这是我如何使用 auth0 进行 facebook 登录。
auth0
.webAuth
.authorize({
scope: 'openid profile email offline_access',
//audience: config.auth0.audience, //option (1)
audience: auth0Domain+'/userinfo', //option (2)
responseType: 'token id_token',
})
.then(auth0Cred => {
console.log("Auth0 Auth Result: "+JSON.stringify(auth0Cred));
dispatch(signInAuth0Successful(auth0Cred));
if (callback != null) {
callback(auth0Cred);
}
dispatch(saveAuth0RefreshToken(auth0Cred.refreshToken));
//return auth0Cred;
})
.catch(error => console.log(error));
对于观众来说,我有两个选择。
当我使用选项 (1) 时,它会给我(长版)accessToken、idToken、scope、expiresIn、tokenType。
当我使用选项 (2) 时,它会为我提供 accessToken、idToken、refreshToken、expiresIn、tokenType(的不透明版本)。
但是,我同时需要长accessToken和refreshToken?可能吗?
说明 - 当您将 audience
用于您自己的 API 时,您选择接收 JWT 访问令牌(长令牌)。如果您只需要调用 Auth0 /userInfo
端点,那么默认行为只是提供一个不透明的访问令牌——这是预期的行为(如果有些混乱)。
出于兴趣,如果您不指定自己的受众,为什么需要 JWT 访问令牌?
但是,要尝试解决您的请求 - 请检查您是否已将 Auth0 仪表板中的客户端设置为 OIDC Conformant
。在 Clients -> Your Client -> Settings - Advanced
下(页面底部)。屏幕截图如下:
如果这不起作用,我们可以探索其他选项 - 因此,如果需要,请在下方发表评论。
使用 OIDC 一致性,您不会收到 SPA 的刷新令牌(隐式流)。相反,请使用 Silent Auth - 请参阅 reference docs here,因此请确保您的客户端类型设置为 Native
。
根据 OP 反馈 - 检查资源服务器是否也启用了 allow_offline_access
。可以使用 Management API 对其进行修补。或者,只需转到 Auth0 控制面板中的 API,然后切换 API 设置页面上的开关。
我正在使用 react-native-auth0 sdk。这是我如何使用 auth0 进行 facebook 登录。
auth0
.webAuth
.authorize({
scope: 'openid profile email offline_access',
//audience: config.auth0.audience, //option (1)
audience: auth0Domain+'/userinfo', //option (2)
responseType: 'token id_token',
})
.then(auth0Cred => {
console.log("Auth0 Auth Result: "+JSON.stringify(auth0Cred));
dispatch(signInAuth0Successful(auth0Cred));
if (callback != null) {
callback(auth0Cred);
}
dispatch(saveAuth0RefreshToken(auth0Cred.refreshToken));
//return auth0Cred;
})
.catch(error => console.log(error));
对于观众来说,我有两个选择。
当我使用选项 (1) 时,它会给我(长版)accessToken、idToken、scope、expiresIn、tokenType。
当我使用选项 (2) 时,它会为我提供 accessToken、idToken、refreshToken、expiresIn、tokenType(的不透明版本)。
但是,我同时需要长accessToken和refreshToken?可能吗?
说明 - 当您将 audience
用于您自己的 API 时,您选择接收 JWT 访问令牌(长令牌)。如果您只需要调用 Auth0 /userInfo
端点,那么默认行为只是提供一个不透明的访问令牌——这是预期的行为(如果有些混乱)。
出于兴趣,如果您不指定自己的受众,为什么需要 JWT 访问令牌?
但是,要尝试解决您的请求 - 请检查您是否已将 Auth0 仪表板中的客户端设置为 OIDC Conformant
。在 Clients -> Your Client -> Settings - Advanced
下(页面底部)。屏幕截图如下:
如果这不起作用,我们可以探索其他选项 - 因此,如果需要,请在下方发表评论。
使用 OIDC 一致性,您不会收到 SPA 的刷新令牌(隐式流)。相反,请使用 Silent Auth - 请参阅 reference docs here,因此请确保您的客户端类型设置为 Native
。
根据 OP 反馈 - 检查资源服务器是否也启用了 allow_offline_access
。可以使用 Management API 对其进行修补。或者,只需转到 Auth0 控制面板中的 API,然后切换 API 设置页面上的开关。