Search code examples
react-nativesingle-sign-onauth0react-native-auth0

How to get refreshToken on react-native-auth0


i'm using react-native-auth0 to handle my SSO. Login works, but my refresh token is null. Why?

This is the code:

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",

In this case, when i call authorize, open correctly auth0 modal, login succesfully with email and password, and the credentials response is:

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

The configuration of auth0 are: enter image description here

enter image description here

How can I get the refresh token and perform the refresh operation? Thanks


Solution

  • Add offline_access to scope in authorize request and enable offline access from the settings.

    The refresh_token will only be present in the response if you included the offline_access scope and enabled Allow Offline Access for your API in the Dashboard.

    See Add Login Using the Authorization Code Flow with PKCE for details.