如何在react-native-auth0上获取refreshToken

问题描述 投票:0回答:1

我正在使用react-native-auth0 来处理我的SSO。 登录有效,但我的刷新令牌为空。为什么?

这是代码:

import {useAuth0} from 'react-native-auth0';

export const LoginScreen = () => {
  const {authorize, error} = useAuth0();

  const onPressLogin = async () => {
    const credentials = await authorize();
  };

  return ....;
};

   "react-native-auth0": "^3.0.2",
    "react-native": "0.72.6",

在这种情况下,当我调用

authorize
时,正确打开auth0模式,使用电子邮件和密码成功登录,凭证响应为:

 {
    "idToken": "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCI........Qjf8JLAzF-wc1oqw",
    "scope": "openid profile email",
    "expiresAt": 1700665033,
    "accessToken": "eyJhbGciOiJkaXIiLCJlbm.......RxDDBy54rT9KGlg",
    "tokenType": "Bearer",
    "refreshToken": null
}

auth0的配置为:

如何获取刷新令牌并执行刷新操作? 谢谢

react-native single-sign-on auth0 react-native-auth0
1个回答
0
投票

offline_access
添加到 authorize 请求的范围,并从设置启用离线访问。

仅当您包含离线访问范围并在仪表板中启用允许 API 离线访问时,refresh_token 才会出现在响应中。

有关详细信息,请参阅使用授权代码流程和 PKCE 添加登录

© www.soinside.com 2019 - 2024. All rights reserved.